views:

49

answers:

4

In my ASP.NET WebForms application, I have a WebForm that contains an UpdatePanel and multiple views used for a wizard like interface.

At the end of the wizard, the user has an option of moving to another page by clicking a button. This new web page needs about 5 values from controls in the previous page.

What is the simplest way to do this? (Edit: ONLY using an HTTP POST with data - this is a requirement as I would use database/session otherwise)

I tried using cross-page posting with no luck, possibly because of my update panel and multiple views?

I tried using Server.Transfer, but this also breaks because of the update panel.

Important:

  1. Data has to be sent via HTTP POST - The data can't be stored anywhere
  2. The scenario can't be changed. I can't put everything on the same page
A: 

You could make a class that describes the data that you need to display on the redirected page. Instatiate a new instance of that at the time the user is filling out the wizard data, populate the new classes' object with the information you need, then add it to the session in the button_Click event before page redirection. On the page you are redirected to, grab the Session object, put it into a variable and extract the data you need.

TheGeekYouNeed
If it doesn't make sense to create a new class for the 5 values (which could be somewhat unrelated), don't force it.
treefrog
I forgot to mention I `must` only use an HTTP POST.
Baddie
It makes sense when dealing with the Session object - to manage one piece of information rather than 5; the number of 5 could easily grow into 8, 10, or more as requirements change as the project rolls on.
TheGeekYouNeed
+1  A: 

The simplest way to do this is by putting those values in the session object.

MCain
Forgot to mention, I `must` only use an HTTP POST.
Baddie
A: 

If they're moving to another page in the solution, you have a few options.

  1. ViewState - The ViewState is sent with the page delivery. It resides in the HTML, but is encrypted so no one can see the information. Depending on the size of the information, your page size could get rather large.
  2. Session - This puts the information client-side via cookies.
  3. Query String - Using the URI. This should only be used if it's non-sensitive information and if you don't want a user to be able to link back to the same action again.
treefrog
I forgot to mention I `must` only use an HTTP POST.
Baddie
ViewState would be the way to go then. If it's a static set of information that can be retrieved, do what Carter said and make a look-up (I'd use an enum) in the page_load of the next page.
treefrog
A: 

I recommend you combine all the relevant pages into one; hiding panels that are not in play. ASP.NET will maintain the values of all the controls for you from post to post. The Viewstate was designed for sceneries like you describe. To keep to Viewstate size to a minimum, make sure you fill lookup values for drop-down controls in their "Init" methods.

You don't want to use the session state. The last thing you want is for the users to loose their data from previous pages because they took too long to answer.

Carter