相关疑难解决方法(0)

ASP.net MVC数据注释DateTime默认值

在我的视图模型中,我有以下属性:

 [Required]
 [DataType(DataType.Date, ErrorMessage="Please enter a valid date in the format dd/mm/yyyy")]
 [Display(Name = "Date of Birth")]
 public DateTime DOB { get; set; }
Run Code Online (Sandbox Code Playgroud)

在我看来,我有以下几点:

<div class="editor-label">
    @Html.LabelFor(model => model.DOB)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.DOB)
    @Html.ValidationMessageFor(model => model.DOB)
</div>
Run Code Online (Sandbox Code Playgroud)

在提交表单之前,DOB的默认值是1/01/0001如何停止自动填充此值,我只想在人们访问此表单时使用空字段?

asp.net-mvc data-annotations

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

asp.net-mvc ×1

data-annotations ×1