This is a migrated thread and some comments may be shown as answers.

How to give an ID to DatePicker

1 Answer 160 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 20 Jan 2014, 07:51 PM
I have this code.  I thought that it would give an ID to the DatePicker.  However, after much debugging, it turns out it changes the name of the parameter which is used on the post.  So the Model Binding was no longer working.

Is this a bug?  I thought that the Name property specified an ID for a control.
@(Html.Kendo().DatePickerFor(m => Model.SearchInfo.StartDate).Name("start-date")

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 21 Jan 2014, 10:41 AM
Hi Greg,

This behavior is expected, because the Name method sets both the name and the id attributes of the widget's HTML element. The For helpers however (i.e DatePicker vs DatePickerFor) automatically set these based on the Model metadata, so using the Name method is rarely necessary. 

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Date/Time Pickers
Asked by
Greg
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or