tags:

views:

550

answers:

3

Hi,

I have an ASP.NET wizard control where I loop back, wiz.MoveTo(wiz.WizardSteps[0]), to the first step in the wizard in the FinishButtonClick event handler.

I then also want to clear all content for all controls in the steps?

The problem is that because of viewstate the controls in the wizard steps remember their values from the previous submission?

I cannot use enableviewstate=false on controls as they need to be able to remember their state (back and forth) between steps?

What is the easiest way to clear the viewstate of all controls only when the FinishButtonClick event occurs?

Thanks!

A: 

Is there anything that shouldn't be cleared? If not, the simplest solution is probably to put in a redirect in the click event handler so everything gets reinitialized.

Tom Clarkson
Thanks Tom, I just happened to stumble upon the exact same solution...After understanding the problem a bit better. ;)
Konrad
+1  A: 

Solved. Also learnt something new about the scope of ViewState in the process...

ViewState is not responsible for storing the modified values for controls such as TextBoxes, DropDowns, CheckBoxes etc. These controls inherit from the IPostBackDataHandler interface. The LoadPostBackData event fires in the page lifecycle, in which the VALUES of the controls load from the form HTTP POST headers... which are resubmitted by the client...

So how to destroy the HTTP POST Headers to clear the control values?

A new request results in new HTTP POST Headers...So I simply do this in the FinishButtonClick event handler:

HttpContext.Current.Response.Redirect(Page.Request.Url.ToString());

This has the added benefit that it goes to Step 1 of the wizard so I also dont have to do... wiz.MoveTo(wiz.WizardSteps[0]).

Hope this helps someone with the same problem.

Konrad
A: 

this last pos works fine but perhaps some javascript to validate the finish click... somethng to think about hummmm

Francis