Asp.net mvc 3 在MVC3中设置模型的默认值

Asp.net mvc 3 在MVC3中设置模型的默认值,asp.net-mvc-3,view,model,properties,default-value,Asp.net Mvc 3,View,Model,Properties,Default Value,这是我的模型的属性: [Required(ErrorMessage = "Debe escribir su fecha de nacimiento")] [Display(Name = "Fecha de Nacimiento")] [DataType(DataType.Date)] public DateTime DateOfBirth { get; set; } 在我的AccountController中,我创建此模型的新对象并将其传递给视图: <div class="editor-

这是我的模型的属性:

[Required(ErrorMessage = "Debe escribir su fecha de nacimiento")]
[Display(Name = "Fecha de Nacimiento")]
[DataType(DataType.Date)]
public DateTime DateOfBirth { get; set; }
在我的AccountController中,我创建此模型的新对象并将其传递给视图:

<div class="editor-label">
    @Html.LabelFor(model => model.DateOfBirth)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.DateOfBirth)
    @Html.ValidationMessageFor(model => model.DateOfBirth)
</div>

@LabelFor(model=>model.DateOfBirth)
@EditorFor(model=>model.DateOfBirth)
@Html.ValidationMessageFor(model=>model.DateOfBirth)
记住,此时这是一个创建表单。模型的属性没有值

但是,这是在我的HTML中呈现的


是否有某种方法可以告诉视图引擎不要在该字段中渲染任何内容?

如果将定义更改为可为null的,则它将以null开头,如果未设置值(默认情况下不设置),则不会显示任何值

public DateTime? DateOfBirth { get; set; }