I\'m new with MVC2, and am having a formatting problem. I have a DateTime property in my Employee model that I would like displayed with the Short Date Time.
This howeve
Try decorating your view model property with the [DisplayFormat] attribute:
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
public DateTime DateRequested { get; set; };
and in your view use the Html.EditorFor
helper:
<%: Html.EditorFor(model => model.DateRequested) %>
<%: Html.ValidationMessageFor(model => model.DateRequested) %>
or if you insist on using textbox helper (don't know why would you but anyway here's how):
<%: Html.TextBox("DateRequested", Model.DateRequested.ToShortDateString()) %>
<%: Html.ValidationMessageFor(model => model.DateRequested) %>