3
這裏是我的模型的屬性:在MVC3模型設置的默認值
[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>
記住,此時這是一個Create窗體。該模型的屬性沒有值。
但是,這是呈現在我的HTML。
是否有某種方式來告訴視圖引擎不會使這一領域的東西嗎?