tags:

views:

32

answers:

3

I have a survey, where you have to click through several pages with questions. I use a "Next" and a "Previous" button for doing this. I use a session for keeping tabs on my position. However, this is a problem.

I use the button_click event to increment the page counter, but since this fires after the page_load event, nothing happens on the first click, and for every click thereafter everything is one page behind because the questions are rendered before the counter is incremented.

Is there any way to solve this without using the query-string?

Comment response 10:15:

My understanding is that the following happens:

  1. The first page loads and the counter is not set. The counter is set to 1. The first page is displayed.
  2. The user clicks the "Next" button, firing a postback.
  3. The page loads, displaying the same set of questions, because the counter is still on 1.
  4. The buttons Click-event is run, incrementing the counter. However, the page is still displaying the old questions.

After this everything is one page behind because the questions are rendered before the click-event is fired, incrementing the page counter.

I'm probably not seeing something obvious here :|

A: 

Why don't you use the out-of-the-box Wizard control? This is what it is designed for. They have solved all of this issues that you are likely to have and it is entirely customizeable.

Scott Gu's blog

MSDN Walkthrough

Daniel Dyson
A: 

Like Pavel said in the comment posting some code to clarify the question might help in seeing where you could have gone awry. There could be several things amiss, first check to make sure your logic is sound in your code. Go through step by step and see if it doing what you are wanting. Setting up break points is also a good idea to find the issue. It could be just a variable out of place (this has happened to me many of times and caused a lot of hair pulling).

Bactos
A: 

I got past it by using the LoadComplete event to set all the "dynamic" text and controls. Since the LoadComplete event of the Page object fires after the postback-events of the controls, this works as I want it to.

Christian W