I have tried different approach to make a dateTime text box, this is the one that works, but the problem is I cannot set a default date.
Here's what I am working on:
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
Then I set the date today, DateTime.Now
like this model.NotifyDate = DateTime.Now;
It doesn't set the date. However, if I remove [DataType(DataType.Date)]
from the model I will get:
I will get the date, but the calendar is gone. What's the problem? Or am I using the datepicker
wrong?
Here's my view:
@Html.EditorFor(m => m.NotifyDate, new { htmlAttributes = new { @class = "form-control input-sm" } })