这个<% Html.EnableClientValidation(); %>
真的能让客户验证没有页面刷新的验证吗?
问题是它在返回formviewmodal时正在进行页面刷新,使用模态时工作正常吗?那么我将如何使用formviewmodal
使其工作这是控制器返回FormViewModel的代码
public class OrganizationGroupFormViewModel
{
public OrganizationGroup OrganizationGroups { get; set; }
public OrganizationGroupFormViewModel() { }
public OrganizationGroupFormViewModel(OrganizationGroup OrganizationG)
{
OrganizationGroups = OrganizationG;
}
}
public class OrganizationGroupsController : Controller
{
public ActionResult Create()
{
OrganizationGroup OrgGroup = new OrganizationGroup
{
int_CreatedBy = Authorization.UserID,
dtm_CreatedDate = DateTime.Now
};
return View(new OrganizationGroupFormViewModel(OrgGroup));
}
[HttpPost]
public ActionResult Create(OrganizationGroup OrgGroup)
{
try
{
if (ModelState.IsValid)
{
OrgGroup.int_CreatedBy = Authorization.UserID;
OrgGroup.dtm_CreatedDate = DateTime.Now;
OrganizationGroupRepository.Add(OrgGroup);
OrganizationGroupRepository.Save();
return View(new OrganizationGroupFormViewModel(OrgGroup));
}
else
return View(new OrganizationGroupFormViewModel(OrgGroup));
}
catch
{
return View(new OrganizationGroupFormViewModel(OrgGroup));
}
}