How to make a wizard with ASP.Net MVC

Our site has several "wizards" where various data are collected on several pages and cannot be linked to the database until the last step.

What is the best / right way to make such a wizard using ASP.Net MVC

edit: My boss is saying no javascript right now - any thoughts on how to get around this limitation?

+46
c # asp.net-mvc wizard
Nov 17 '08 at 22:11
source share
8 answers

I do not believe that there is a better / correct way, but the way I will do it is ...

Each master gets his own page. Each step gets its own div. All steps are in the same form.

The previous / next buttons will hide / show the div at each step of the process. The submit button of the last step represents the entire form. It would be pretty trivial to implement this with jQuery, and it would be easy to maintain, since all the steps in the wizard are in the same ViewPage.

On the controller side, you have two controller methods: the version of HttpVerbs.Get, which will prepare the form for viewing, and the version of HttpVerbs.Post, which will take the FormsResult form and analyze it to get the information needed to send the user responds to storage / other processes.




Wow, your boss stinks.

This answer almost elegantly works for those ****** for which javascript is disabled (yes, both of them). You can configure it to hide the next previous buttons with CSS and show them in your javascript code. Thus, people with javascript see the wizard, and people without javascript will see the whole form (without the next / prev buttons).

Another option is to create a view for each step of the wizard. You can save intermediate form results in a session. This method will take a lot of time and effort to implement, which means that you could probably squeeze some overtime from your boss, when you demonstrate in about twenty minutes the effort that you spend during lunch, how easy it is to implement a javascript route .

+44
Nov 17 '08 at 22:29
source share

If you cannot use JavaScript, make each step a view using the method in the controller and save your data in the session until you are ready to send it to the database.

You can make your Next and Prev buttons using the ActionLink HtmlHelper method.

+20
Nov 18 '08 at 17:05
source share

Another way is to save the incomplete object that you build using the wizard to the database and simply transfer the primary key to the next step of the wizard. I know that this means that you need to make some database fields null, but they have the added advantage that you can save the primary key in a cookie and allow the user to return to the wizard again later. This parameter does not require javascript or session state.

+12
Feb 03 '09 at 19:49
source share

Make different panels on the client side ... everything is in the same form ... and when the last submit button is pressed, you can publish all the values ​​at the same time.

+4
Nov 17 '08 at 22:28
source share

If you cannot use Javascript and don’t want to waste server resources on session variables, you can also serialize and deserialize the values ​​entered at different stages and transfer them back and forth using a hidden input field. A bit like ViewState in ASP.NET Webforms.

+3
Nov 24 '08 at 22:13
source share

I put together a login wizard and documented the ideas behind it on my blog if that helps: link text

+2
Sep 22 '09 at 20:03
source share

You can use the simple MVCWizard.Wizard component available on NuGet. WizardController allows you to create a wizard with a partial view. There is also an AutoWizardController that displays the entire wizard in one view. All of these components work with a session to store model state.

+1
Sep 12 '11 at 15:59
source share

There is a very simple, flexible and extensible method in this question: How to simplify my modal dialogs with variable rotation in ASP.NET MVC

+1
Dec 19 '11 at 16:36
source share



All Articles