我的模特
[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>
最佳答案 将您的属性声明为字符串
[Display(Name = "Tanggal Lahir")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public string TanggalLahir { get; set; }