【发布时间】:2011-12-07 10:15:28
【问题描述】:
如果用户单击使用上述地址,则该值在 Address1 中设置并被禁用。 该值未在表单提交中传递,但我可以从 Controller 中的 model.Address 获取它。如果 ModelState.IsValid 无效,我将字段 model.Address1 返回为空,如何使用 model.Address 填充它?
View
$("#MailAddressAsAbove").click(function () {
if ($(this).attr("checked") == true) {
$('#Address1').attr("disabled", true);
}
}
控制器
[HttpPost]
public ActionResult Enquiry(PersonViewModel model)
{
if (model.MailAddressAsAbove)
{
model.Address1 = model.Address;
}
if (!ModelState.IsValid)
{
return Enquiry();
}
}
谢谢
【问题讨论】:
标签: jquery asp.net-mvc model-view-controller asp.net-mvc-2