How to give an ID to DatePicker

2 posts, 1 answers
  1. Greg
    Greg avatar
    4 posts
    Member since:
    Dec 2013

    Posted 20 Jan 2014 Link to this post

    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")

  2. Answer
    Alexander Popov
    Alexander Popov avatar
    1411 posts

    Posted 21 Jan 2014 Link to this post

    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. 

    Alexander Popov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET AJAX bannerTelerik UI for ASP.NET Core is out
Back to Top