我正在使用带有 Razor 的 ASP.NET MVC 3,下面是我查看代码的示例。
用户应该能够编辑他们的所有详细信息,除了“EmailAddress”字段。对于那个领域,我只使用过Html.DisplayFor(m => m.EmailAddress)
.
但是当这个表单被发布时,除了EmailAddress
.
发布时如何在模型中恢复电子邮件?我应该使用其他帮助DisplayFor
吗?
@using (Html.BeginForm()) {
@Html.ValidationSummary(true, "Account update was unsuccessful. Please correct any errors and try again.")
<div>
<fieldset>
<legend>Update Account Information</legend>
<div class="editor-label">
@Html.LabelFor(m => m.EmailAddress)
</div>
<div class="editor-field">
@Html.DisplayFor(m => m.EmailAddress)
@*@Html.ValidationMessageFor(m => m.EmailAddress)*@
</div>
<div class="editor-label">
@Html.LabelFor(m => m.FirstName)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.FirstName)
@Html.ValidationMessageFor(m => m.FirstName)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.LastName)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.LastName)
@Html.ValidationMessageFor(m => m.LastName)
</div>
<p>
<input type="submit" value="Update" />
</p>
</fieldset>
</div>
}
请就此给我建议。