1

I'm creating a 5 step wizard using MVC. I've created the first step and obtained the values selected from the form.

The form layouts of the next steps will depend on the options the user has selected in step1.

Could someone please advise the best way to achieve this? I've thought about dynamically altering the steps using JavaScript and then after all steps are completed, submit all the data.... Or would it be best to submit the data after each step?

If I did submit the data after each step, is it possible to access the same class where the data will be stored between controllers?

I'd normally use session variables in php, is there something similar I can do using MVC?

Sorry I'm quite new to MVC and need a little help to point me in the right direction

Thanks

A Houghton
  • 372
  • 5
  • 18
  • I'd build it client side and have JS handle the steps before a single submission, but that's mostly just personal preference. – DBS Mar 31 '16 at 17:43
  • It depends on what extent your wizard form needs to be navigable, how complicated it is, and if any server-side processing needs to happen in-between wizard form pages. Please provide more information about your scenario. – Dai Mar 31 '16 at 17:44
  • I suggest you do the steps using JavaScript and submit all the data when you finish like you thought. The ASP.NET MVC has session like PHP too if you prefer send the step to the server. – Rodrigo Kiguti Mar 31 '16 at 17:55
  • What kind of validation were you planning on using? Sometime front-end(JS) styled steps can be a pain in the butt for validations and form navigation. I would think 5 steps could get a little cluttered with client side steps. – Mark Mar 31 '16 at 17:59
  • Yes, you can use the [Session store](http://stackoverflow.com/questions/14138872/how-to-use-sessions-in-an-asp-net-mvc-4-application). You could also save a partial transaction in a database. It all depends on your application needs. – Jasen Mar 31 '16 at 18:25

1 Answers1

0

This sounds like a great candidate for jQuery Steps.

With this approach you can just create one long form and specify each step of the wizard with the plugin.

It will allow you to use one strongly typed view model and reduce the amount of server-side code you have to write (and maintain).

Elliott
  • 2,035
  • 20
  • 23