By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Multiview and viewstate

P: n/a
I noticed something interesting when using the Multiview control and was
wondering if someone could shed some light on the inner workings of all
of this so I can better understand what's going on here.

Basically I'm using the Multiview as a kind of wizard with back/next
buttons. At step one, I ask a question... let's say "How old are
you?"... and I use the response to this question to determine the
contents of the controls on subsequent steps of the multiview.

To keep things simple, let's imagine that step has a label that says "A
year ago you were x years old" and step 3 in my little wizard has an
equally useless label that says "Next year you'll be y" where x = age -
1 and y = age + 1...

Now, when I'm writing code in the "Next" button in the view for step 1,
I first change the active view in my multiview control, then I inspect
the value of the ageTexEdit.Text control and use this to set the text
for steps 2 and 3 of the wizard... something like:

// Set active view

// Read in response to step one and update steps 2 and 3 accordingly
int age = int.Parse(ageTexEdit.Text);
step2Label.Text = String.Format("A year ago you were {0} years old",
age - 1);
step3Label.Text = String.Format("Next year you'll be {0}", age + 1);
Also, presume that before any of the code above has executed the
properties for step2Label.Text and step3Label.Text are "step 2" and
"step 3" resepectively.

Now, if I now fire up my wizard and enter my age as "10" and click on
the next button, in step 2 everything looks as it should... it says "A
year ago you were 9 years old". However, when I click on the "Next"
button in step 2 of the wizard, which simply does the following:


The text in step three still says "step 3"... so the code that was run
successfully in the On Click event handler for the next button in step
one DIDN'T do what I was expecting. It set the value of step3Label.Text
correctly, however this value did NOT get stored in the viewstate for
the form.

Can anyone explain to me why this is the case?

By the way, it's easy enough to work around this by setting the text for
step2Label and step3Label in the ActiveViewChanged event of the
multiview when the view that each control is contained in becomes
visible/active. So I'm not looking for a "workaround" to this - that's
very simple. I'm simply looking to better understand the mechanics of
all this and understand why the actual behavior is not what I was expecting.


Best Regards,

James Crosswell LLC
Dec 11 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.