0
這是否<% Html.EnableClientValidation(); %>
真的使客戶端驗證,驗證沒有頁面刷新或不?ASP.NET MVC 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));
}
}
它會適當地工作,如果我們從控制器返回FormViewModel? – maztt 2010-06-06 09:29:35
包含哪些部分視圖是什麼?請更具體一些,描述你的場景,提供一些示例代碼。 – 2010-06-06 09:35:27