问题描述
- 当我将视图模型传递给方法时,它会崩溃,但它可以与 FormCollection 一起使用,或者没有将任何内容传递给 onpost 方法。
[HttpPost]
[AutoValidateAntiforgeryToken]
public ActionResult Update(CustomerInformation model)
{
if (ModelState.IsValid)
{
//save
var UpdateRecord = customerServices.Update(model);
if (UpdateRecord)
{
return RedirectToAction("Details");
}
}
}
@model Customer.Models.CustomerInformationDetails
@using Customer.Models.CustomerInformation
@{
var customerName = Model.Name;
ViewData["Title"] = customerName;
}
<h1>Edit information for @customerName</h1>
<hr />
@using (Html.BeginForm("Update","Customer",FormMethod.Post))
{
<div class="form-group">
@Html.Label("Introduction","Introduction:",htmlAttributes: new { @class = "control-label col-md-10" })
<div class="col-md-10">
@Html.EditorFor(model => model.Introduction,new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
<div class="form-group">
@Html.Label("Contact Person","Contact Person:",htmlAttributes: new { @class = "control-label col-md-10" })
<div class="col-md-10">
@Html.EditorFor(model => model.ContactPerson,new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
<div class="form-group">
<input type="submit" value="Update" class="btn btn-primary"></input>
</div>
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)