加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – ASP.NET DisplayFormat dd / MM / yyyy无效

发布时间:2020-12-16 09:41:44 所属栏目:asp.Net 来源:网络整理
导读:我的模特 [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) 但
我的模特

[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; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读