Search code examples
asp.net-mvc-3datepickertelerik-mvc

Telerik MVC 3.0 DatePicker dosen't seems to work While Binding to a Collection?


In my MVC 3.0 Razor Engine Project

I am using Telerik DatePicker It seems to be Telerik Date Picker is having some issues while binding to Collections. as mentioned here on Telerik Forum

This is my Code

@(Html.Telerik().DatePicker()
    .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .HtmlAttributes(new
        {
            id = ViewData.TemplateInfo
                         .GetFullHtmlFieldId(string.Empty)
                         .Replace("[", "_")
                         .Replace("]", "_") + DateTime.Now.Millisecond.ToString()
        })
    .Value(Model > DateTime.MinValue? Model : DateTime.Today)
)

This is my View

@Html.EditorFor(model=>Model.EndDate)

though This brings the value calender Icon but when I click on Icon or text box it wont show the calender to pick date.


Solution

  • Hey I could fix my problem. just use below line to have the bind date to Telerik DatePiker and this works

     @(Html.Telerik().DatePickerFor(model=>Model.Date))