我在页面上嵌套了表单。
@using (Html.BeginForm())
{
@Html.TextBoxFor(model => model.ComapnyName, new { @class = "form-control", placeholder = @Resources.Customers.ComapnyName })
@Html.ValidationMessageFor(model => model.PhoneNuComapnyNamember, "", new { @class = "text-danger" })
// other stuff
Add
//bootstrap modal
@using (Ajax.BeginForm("CreateCustomersDepartments", "Customers", null, new AjaxOptions
{
HttpMethod = "Post",
UpdateTargetId = "departmentsId",
OnSuccess = "$('#departmentsModal').modal('hide')"
}))
{
@Html.TextBoxFor(model => model.Name, new { @required = "require", @class = "form-control", placeholder = Resources.Common.Name })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
// other stuff
//Create departments
}
//Create company
}
当我单击“提交”按钮(“为主窗体创建”)时,需要验证器保持字段来自模态(depoartments add)。我从添加部门开始,然后单击modalpopup上的提交按钮,主窗体保留验证器。
我试过
但页面无效代码未来到控制器。
在asp.net(网络表单)上我使用validationGroup,如何获得相同的效果