Reputation: 376
I am trying to use Telerik MVC DatePicker in my project. Here is the situation:
I have a model which have :
...
[DataType(DataType.Date)]
public System.Nullable<DateTime> EndDate { get; set; }
...
My ProjectCreate view has strong type of the model given above
Between
@using (Html.BeginForm(null, null, FormMethod.Post, new { Class="ym-form ym-columnar" }))
{
...
}
I have:
@(Html.Telerik().DateTimePickerFor(c => c.EndDate)
.Name("EndDatePicker")
Within my action
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ProjectCreate(ProjectView view)
{
...
}
the
view.EndDate
value is always null whichever date I choose.
I have googled a lot but couldn't find what the problem is.
Upvotes: 1
Views: 3093
Reputation: 30671
That's because you are setting the Name
of your datepicker. You don't need that when using DatePickerFor
:
@(Html.Telerik().DateTimePickerFor(c => c.EndDate))
Upvotes: 3