MVC Validation with ModelState.isValid through a wizard

Posted by Emmanuel TOPE on Programmers See other posts from Programmers or by Emmanuel TOPE
Published on 2011-11-30T15:20:52Z Indexed on 2011/11/30 18:16 UTC
Read the original article Hit count: 330

Filed under:
|

I'm working on a small educational project on MVC 3, and I'm facing a small problem, when attempting to handle validation in my application through a wizard.

I tried to get benefit from the ability of MVC3 to deliver content of a different view using the same URL, when handling an [HttpPost] method on a page.

I my case,my main model's class contains about ten [Required] properties, that I would like to expose through a small wizard in 3 steps , So I want that the user may be able to enter his personal informations in the first step, then respond to some questions in the second stepp and finally receive a confirmation mail from the web application whit his credentials in the last step.

I can't access the last step, because of the ModelState.isValid method that I use to handle validations, and which can't perform properly if I define some properties as [Required], but don't put them on the first view.

As the replies to those questions remain in a couple of choices, I've thinked that I may use some nullable bool? for in order to avoid validation issues, but know that it's not the proper way.

Are there someone who would like to help me find a way to extend my validation to those three steps ? Thanks in advance and sorry for my english, I'm not a native speaker.

© Programmers or respective owner

Related posts about asp.net-mvc

Related posts about validation