This is my first time working on a MVC project. Please bear with me.
I have this user registration form. We have five different user types. I have a main View page and five different partial views. I display the right partial view depending on what user type was selected.
When the form is submitted, I have to do some server side validation.
[HttpPost]
public ActionResult UserRegistration(FormCollection form)
{
//Perform some validation
//If validation fails
ModelState.AddModelError("", "some error message");
}
I want to re-display the User Registration form, with the right partial view that the user was on (UserType is part of form collection). And I want to display the ModelState error message. How do I do that?
new2aspdotne...
Participant
1179 Points
354 Posts
Error handling with multiple partial views
Apr 13, 2012 01:27 AM|LINK
Hi,
This is my first time working on a MVC project. Please bear with me.
I have this user registration form. We have five different user types. I have a main View page and five different partial views. I display the right partial view depending on what user type was selected.
When the form is submitted, I have to do some server side validation.
[HttpPost]
public ActionResult UserRegistration(FormCollection form)
{
//Perform some validation
//If validation fails
ModelState.AddModelError("", "some error message");
}
I want to re-display the User Registration form, with the right partial view that the user was on (UserType is part of form collection). And I want to display the ModelState error message. How do I do that?
Thanks.