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

DatePicker in MVC bound to a Text field

2 Answers 1486 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 2
Ian asked on 25 Jul 2013, 06:31 PM
I am converting a site wirtten in MVC to Kenod.

In a model, the date field, "StartDateSelected" is text and changing that would be difficult.

Is there a way to make the DatePickerFor bind to a text field instead of DateTime?

@(Html.Kendo().DatePickerFor(model => model.StartDateSelected)
            .Name("StartDateSelected")
            .Min("1/1/1999")
            .Value(Model.StartDateSelected)
      )

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 29 Jul 2013, 11:25 AM
Hello Ian,

Basically you can use the DatePicker helper instead of DatePickerFor and you can specify the Name of the widget to be the same as the name of the property.

Also if you cast the string to Date to set the initial value everything else should be working fine. 

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shirish
Top achievements
Rank 1
answered on 17 Apr 2020, 09:11 PM

Hi Ian,

Please remove the .Name() method

 

@(Html.Kendo().DatePickerFor(model => model.StartDateSelected)
            .Min("1/1/1999")
            .Value(Model.StartDateSelected)
      )

Tags
Date/Time Pickers
Asked by
Ian
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Shirish
Top achievements
Rank 1
Share this question
or