C# 模型活页夹-如何制作可选活页夹
我希望将属性DateOfBirth设置为与模型绑定器相关的可选属性C# 模型活页夹-如何制作可选活页夹,c#,asp.net-mvc-4,.net-4.5,C#,Asp.net Mvc 4,.net 4.5,我希望将属性DateOfBirth设置为与模型绑定器相关的可选属性 public class RegisterModel { [Required] public int MP_CustomerID { get; set; } [Required] [DataType(DataType.Password)] public string Password { get; set; } [Required] [DataType(Dat
public class RegisterModel
{
[Required]
public int MP_CustomerID { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
[Required]
[DataType(DataType.Password)]
[Compare("Password")]
public string PasswordConfirm { get; set; }
[Required(AllowEmptyStrings = true, ErrorMessage="This is the error message")]
public DateTime DateOfBirth { get; set; }
public int NoOfVehicles { get; set; }
}
我已经尝试一起删除该属性,但它仍然根据需要对其进行分类
我哪里出错了?您应该使其为空
public DateTime? DateOfBirth { get; set; }
你应该让它为空
public DateTime? DateOfBirth { get; set; }