I have this attribute in my view model:
[DataType(DataType.DateTime)] public DateTime? StartDate { get; set; }
If I want to display a date or fill in a date text field, I have the following data:
<%: Model.StartDate %> <%: Html.TextBoxFor(m => m.StartDate) %>
Whenever a date is displayed, it is displayed as follows: 01/01/2011 12:00:00 AM
But I would like to show only 01/01/2011
Is there a way to apply a display format with data annotations? I do not want every time I show the date, add code to format it.
Steven Mar 09 '11 at 10:22 2011-03-09 22:22
source share