我使用ASP.NET MVC 3与Razor,下面是从我的视图代码的示例。
除了“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> }
请告诉我这个。
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。