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.
我有一个ASP.NET向导控件,我循环回来,wiz.MoveTo(wiz.WizardSteps [0]),到FinishButtonClick事件处理程序向导的第一步。
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?
问题是,由于viewstate,向导步骤中的控件记住了以前提交的值?
I cannot use enableviewstate=false on controls as they need to be able to remember their state (back and forth) between steps?
我不能在控件上使用enableviewstate = false,因为他们需要能够记住步骤之间的状态(来回)?
What is the easiest way to clear the viewstate of all controls only when the FinishButtonClick event occurs?
仅当FinishButtonClick事件发生时,清除所有控件的视图状态的最简单方法是什么?
Thanks!
2 个解决方案
#1
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.
有什么不该清除的吗?如果没有,最简单的解决方案可能是在click事件处理程序中添加重定向,以便重新初始化所有内容。
#2
Solved. Also learnt something new about the scope of ViewState in the process...
解决了。还学习了一些关于ViewState范围的新内容......
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...
ViewState不负责存储TextBoxes,DropDowns,CheckBoxes等控件的修改值。这些控件继承自IPostBackDataHandler接口。 LoadPostBackData事件在页面生命周期中触发,其中控件的VALUES从HTTP POST头文件加载...由客户端重新提交...
So how to destroy the HTTP POST Headers to clear the control values?
那么如何销毁HTTP POST Headers以清除控件值呢?
A new request results in new HTTP POST Headers...So I simply do this in the FinishButtonClick event handler:
一个新的请求导致新的HTTP POST标头...所以我只是在FinishButtonClick事件处理程序中执行此操作:
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])
.
这有额外的好处,它转到向导的第1步,所以我也不必做... wiz.MoveTo(wiz.WizardSteps [0])。
Hope this helps someone with the same problem.
希望这可以帮助有同样问题的人。
#1
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.
有什么不该清除的吗?如果没有,最简单的解决方案可能是在click事件处理程序中添加重定向,以便重新初始化所有内容。
#2
Solved. Also learnt something new about the scope of ViewState in the process...
解决了。还学习了一些关于ViewState范围的新内容......
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...
ViewState不负责存储TextBoxes,DropDowns,CheckBoxes等控件的修改值。这些控件继承自IPostBackDataHandler接口。 LoadPostBackData事件在页面生命周期中触发,其中控件的VALUES从HTTP POST头文件加载...由客户端重新提交...
So how to destroy the HTTP POST Headers to clear the control values?
那么如何销毁HTTP POST Headers以清除控件值呢?
A new request results in new HTTP POST Headers...So I simply do this in the FinishButtonClick event handler:
一个新的请求导致新的HTTP POST标头...所以我只是在FinishButtonClick事件处理程序中执行此操作:
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])
.
这有额外的好处,它转到向导的第1步,所以我也不必做... wiz.MoveTo(wiz.WizardSteps [0])。
Hope this helps someone with the same problem.
希望这可以帮助有同样问题的人。