Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 模型活页夹-如何制作可选活页夹_C#_Asp.net Mvc 4_.net 4.5 - Fatal编程技术网

C# 模型活页夹-如何制作可选活页夹

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

我希望将属性DateOfBirth设置为与模型绑定器相关的可选属性

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