I am working with jQueryUI Datepicker and this is the code that I use in the view
@model myprojectName.WebSite.DataModel.AvailableDate <script> $(function () { $("#datepicker").datepicker(); }); </script> <h3 class="headerColorWhite">Book a session with Mike</h3> <p class="mainText">Select a date that you wish to train with Mike</p> @using (Html.BeginForm()) { <div class="editor-field left" id="datepicker"> @Html.HiddenFor(model => model.DateAvailable, new {@class = "datepicker"}) @Html.ValidationMessageFor(model => model.DateAvailable) </div> <div class="col-md-10 left"> <input type="submit" value="Search Available Slots" class="btn btn-default left" /> </div> }
When I click submit \ search available slots, this does not seem to return my selected date back to the model.
This is a model that conveys a date.
public partial class AvailableDate { private DateTime? _DateAvailable; [DataType(DataType.Date)] [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd-MM-yyyy}")] public System.DateTime DateAvailable { get { return _DateAvailable ?? DateTime.Today; } set { _DateAvailable = value; } } }
Could you tell me where I am wrong and what I need to do to fix this.
--------------- edit to show receipt and publication methods ---------------
// GET: Bookings public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(AvailableDate availableDate) { return View(); }
source share