views:

65

answers:

4

Hi everyone, another ASP.NET MVC question.

Assume the following scenario. You have three controllers:

  1. getFirstData
  2. getSecondData
  3. useFirstData

The workflow of your site requires that the user first uses the getFirstData controller, and inputs some data (lets say an int) in the view. I then need to use the second controller (getSecondData) for something else. Only then does he use the third controller (useFirstData), and needs the original data he inputted in the first controller.

What is the most appropriate way to hang on to that data?

I can pass it along in the model I created through the controllers, but that requires me to "update" the value I pass inside the views, which seems "hackish".

A global variable seems "wrong".

What is the standard way?

Thank you,

Tom

+1  A: 

It sounds like you're trying to create a wizard type workflow. Here are some other questions which might help.

How do I make a wizard with asp.net mvc
How do I handle page flow in MVC, particularly asp.net

Timothy Strimple
+4  A: 

Use dictionary TempData

Alex Maslakov
I'm not too happy with this solution, but it's too late to change the entire flow. I mean, it's never too late, but it's too much of a hassle and isn't worth it.
Tom Teman
+1  A: 

Just save to the database between each step.

If you don't want to do a round-trip, try a JQuery Wizard plugin, like this one.

Robert Harvey
A: 

If you need a Wizard and you're using jQuery give a look to jWizard. It rocks!

Lorenzo