Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Empty value in Kendo DatePicker

I need the default value of datetime picker to be empty.

@(Html.Kendo().DatePickerFor(model => model.RevisionDate)
              .Name("RevisionDate")
                )

"RevisionDate" is a datetime property in a asp.net mvc model.

how it's currently being displayed

enter image description here

and i need to display it as below

enter image description here

like image 309
chamara Avatar asked Dec 30 '13 10:12

chamara


Video Answer


2 Answers

Your RevisionDate property is by default set to DateTime.MinValue which is 01/01/0001 ( all DateTime properties behave like that). This is why the Kendo UI DatePicker shows it like that. The solution is to make the property a nullable DateTime (DateTime?) whose default value is null.

like image 108
Atanas Korchev Avatar answered Oct 22 '22 13:10

Atanas Korchev


If you don't want to make the property nullable, you can also do it like this:

@(Html.Kendo().DatePickerFor(m => m.Property).HtmlAttributes(new { value = "" }))
like image 37
mctl87 Avatar answered Oct 22 '22 12:10

mctl87