I am using MVC4 with the Razor view engine. My controller is as follows:
public ActionResult Index()
{
return View(new EmployeeIndexViewModel
{
ToDate = DateTime.Now
});
}
My View Model is as follows:
public class EmployeeIndexViewModel
{
[DataType(DataType.Date)]
public DateTime ToDate { get; set; }
}
On my view I have a simple EditorFor()
call:
@Html.EditorFor(model => model.ToDate)
But still get a default (masked) value in my date picker:
QUESTION:
How can I get today's date (from controller) to display here instead?