我希望使属性 DateOfBirth 相对于模型 Binder 可选
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; }
我是一名优秀的程序员,十分优秀!