ASP.Net Wizard - Clean Up Web Control Content

I have an ASP.NET control where I go back wiz.MoveTo(wiz.WizardSteps[0])

to the first step of the wizard in the FinishButtonClick event handler.

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

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

I can't use enableviewstate = false on controls as they have to remember their state (back and forth) between steps?

What is the simplest way to clear the view from all controls only when the FinishButtonClick event is raised?

Thanks!

0


a source to share


2 answers


Is there something that shouldn't be cleaned up? If not, the simplest solution is probably to include a redirect in your click event handler so that everything is reinitialized.



+2


a source


solvable. Also learned something new about the scope of ViewState in progress ...

ViewState is not responsible for saving changed values ​​for controls such as TextBoxes, DropDowns, CheckBoxes, etc. These controls inherit from the IPostBackDataHandler interface. The LoadPostBackData event is fired in the page lifecycle, in which the VALUES of the controls are loaded from the form's HTTP POST headers ... which are resubmitted by the client ...

So how do you destroy the HTTP POST headers to clear the control values?

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



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

      

This has the added advantage and it proceeds to step 1 of the wizard, so I also do not need to do ... wiz.MoveTo(wiz.WizardSteps[0])

.

Hope this helps someone with the same problem.

+1


a source







All Articles