在您的模型定义中,将
DisplayFormatAttribute添加到DateTime
属性中:
[displayFormat(ApplyFormatInEditMode = true,DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime Date { get; set; }
然后在您的查看电话中:
<%=Html.EditorFor(m => m.Date)%>
如果一切顺利,您应该获得一个TextBox,其值以属性定义中指定的格式填充。