I want to show only date in my HTML.editorFor not date and time. i have tried with two different ways but dosn’t work.
her’s my code with to different trial :
<%: Html.EditorFor(model => model.Dd.ToShortDateString())%>
<%: Html.ValidationMessageFor(model => model.Dd) %>
<br />
<%: Html.LabelFor(model => model.Df) %>
<br />
<%: Html.EditorFor(model => model.Df, Model.Df.ToShortDateString()) %>
<%: Html.ValidationMessageFor(model => model.Df) %>
Any one got i idea ho to do it?
You could decorate your view model property with the
[DisplayFormat]attribute:This allows you to specify the format you wish to use when displaying and editing the property in the view.