【发布时间】:2011-08-21 21:16:25
【问题描述】:
这是我的模型的属性:
[Required(ErrorMessage = "Debe escribir su fecha de nacimiento")]
[Display(Name = "Fecha de Nacimiento")]
[DataType(DataType.Date)]
public DateTime DateOfBirth { get; set; }
在我的 AccountController 中,我创建了这个模型的一个新对象并将其传递给 View:
<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>
请记住,此时这是一个创建表单。模型的属性没有值。
但是,这是在我的 HTML 中呈现的。
有没有办法告诉视图引擎不要在这个字段中渲染任何东西?
【问题讨论】:
标签: asp.net-mvc-3 view model properties default-value