我创建了一个基于 Windows 窗体的应用程序,并且正在使用简单的会员帐户模型。在注册表单上,当应用程序上传到 azure 时,我遇到了日期格式问题。
在本地,我可以输入“31/10/2013”格式,但在 azure 托管应用程序上,我必须以“10/31/2013”格式输入。如何覆盖验证以允许使用 DD/MM/YYYY 格式
我的寄存器模型如下:
public class RegisterModel
{
[Required]
[Display(Name = "Username")]
public string UserName { get; set; }
[Required]
[Display(Name = "Forename")]
public string Forename { get; set; }
[Required]
[Display(Name = "Surname")]
public string Surname { get; set; }
[Required]
[Display(Name = "DOB")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.MM.yyyy}")]
public DateTime DOB { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Secret Answer")]
public string SecretAnswer { get; set; }
}
我尝试将日期格式应用于上述 DOB 属性,但在天蓝色上它仍在验证 MM/DD/YYYY