Issue:
I had declared in my model the following[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime? AuditDate { get; set; }
@Html.EditorFor(model => model.AuditDate, new { htmlAttributes = new { @class = "form-control" } })
But it was not working!
Then I noted that the Default Displayformat is defined to work with @Html.Display or @Html.DisplayFor and inorder to get it working with Editor controls you need to apply ApplyFormatInEditMode = true.
Source:
https://forums.asp.net/t/1857087.aspx?DateTime+DisplayFormat+seems+to+have+no+effect+MVC4+Razor+
No comments:
Post a Comment