我想顯示一個日期。我的viewmodel代碼示例如下:格式在ASP.NET MVC中的日期時間3
[Display(Name = "Date of birth")]
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
[DataType(DataType.Date, ErrorMessage = "Enter correct date (e.g. 23.05.1980)")]
public DateTime CustomerBirthday { get; set; }
一切正常顯示。但是當我想提交一個表單時,如果第一個數字大於12,那麼它不會通過驗證,因爲它期望格式爲MM.dd.yyyy而不是dd.MM.yyyy。 如何強制模型聯編程序使用我的DateTime模式(dd.MM.yyyy)並忽略文化設置。