Wednesday, May 8, 2013

Date Format in ASP.NET MVC Form Edit Mode


You might get the date displayed in the TextBox in the below format.

09/05/2013 12:00:00 AM

To remove the 12:00:00 AM part from the text you need to do the following things.

Set the display format in date property.

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime ArrivedDate { get; set; }


Modify the view as below.

<%: Html.EditorFor(model => model.ArrivedDate)%>

No comments:
Write comments
Recommended Posts × +