Wizard Control and IsPostBack

R

rdlauer

I'm in a catch-22 with a wizard control and wonder if anyone has any
ideas:

It appears as though every time you load a wizard control step, you are
doing a postback, which makes sense. That causes problems, though, when
you have actions in a step that should only be executed if IsPostBack =
False (which will never be true on any step greater than #1). Example:

I have a two (or more) step process that I'm using a wizard control
for. I wrote a method called "OnNext" that is called every time I hit
the "next" button in my control.

The 1st wizard step is just a textbox (txtStep1). The 2nd wizard step
is also just a textbox (txtStep2).

On WizardStep2.Load, I set txtStep2.Text = txtStep1.Text. However, this
should ONLY happen if IsPostBack = False, otherwise any user entry into
txtStep2.Text will be overwritten by txtStep1 (in case of a validator
going off or whatever) again.

The catch is that WizardStep2.Load is, in itself, a postback, since
we're really doing a postback from Step1.

I feel like I'm missing some really obvious wizard control option here,
but I just can't figure this out. Thanks in advance for any help.
 
M

Mike MacMillan

rdlauer,
this is an issue i came across a while back when authoring my own
wizard control. since each step postsback, testing the IsPostBack
property is useless (as you said). my work around was for each step to
define a property that persists its value in viewstate. this way, if
you ever go further then one postback away from a step, it will lose
its viewstate value, letting you know you need to reinitialize its
data. as for persisting whether a step is complete or not, you can
either use a session object, or integrate the step data into the
viewstate via overriding the Load and SaveViewState methods in the base
wizard class.

hope this helps,
Mike MacMillan
 
R

rdlauer

Thanks for the reply. I ended up using a hidden field on each step with
a default value of "no" and an id of "StepX_Submitted". In the step
load method, I check to see if that value is "no"...if so, execute some
code. In my OnNext method (executed whenever the "next" button is
clicked) I set the value for the hidden field on that step to be "yes".

Not very elegant, but it works. I'd be interested to hear how this is
"supposed" to be done though! Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top