我的模型
[Display(Name = "Tanggal Lahir")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime TanggalLahir { get; set; }我的观点
@Html.EditorFor(m => m.TanggalLahir)但它仍然使用MM/dd/yyyy显示格式数据。
甚至是我的web.config
<system.web>
<globalization uiCulture="en" culture="en-GB"/>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="30000000" />
</system.web>发布于 2015-10-29 12:53:37
将属性声明为字符串
[Display(Name = "Tanggal Lahir")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public string TanggalLahir { get; set; }发布于 2015-10-29 12:26:03
@Html.EditorFor(m => m.TanggalLahir, "{0:dd/MM/yyyy}", new {maxlength = 10})你可以试试这样的东西..
发布于 2015-10-29 12:28:26
1如果你不能让它在模型上工作,你可以在视图上尝试它。
@Html.EditorFor(m => m.TanggalLahir, "{0:dd/MM/yyyy}", new {maxlength = 10})(或)
@Html.EditorFor(m => m.TanggalLahir, new { @Value = Model.StartDate.ToString("dd/MM/yyyy") })https://stackoverflow.com/questions/33405785
复制相似问题