I am using asp.net mvc2 and having a basic Page that includes a Partial View within a form
<% using (Html.BeginForm())
{ %>
<% Html.RenderAction("partialViewActionName", "Controllername"); %>
<input type="submit" value="Weiter" />
<% } %>
When I submit the form, the httpPost Action of my Page is called, and AFTER that the httpPost Action of my Partial View is called
[HttpPost]
public virtual ActionResult PagePostMethod(myModel model)
{
// here I should know about the validation of my partial View
// If partialView.ModelState is valid then
// return View("success");
// else return View(model)
}
[HttpPost]
public virtual ActionResult partialViewActionName(myModel model)
{
ModelState.AddModelError("Error");
return View(model);
}
But as I am doing the Validation in the httpPost Method of my Partial View (because I want to use my Partial View in several Places) I cant decide if my hole page is valid or not.
Has anyone an Idea how I could do this? Isn´t it a common task to have several partial Views in a page but have the information about validation in the page action methods?
Thanks very much for your help!!