【发布时间】:2011-04-24 21:44:09
【问题描述】:
我想知道如何在每次点击向导控件的下一步按钮以显示 ActiveStepIndex 时更新我的 URL 的查询字符串。
例子:
- http://ApplicationName/Default.aspx?Step=1
- http://ApplicationName/Default.aspx?Step=2
- http://ApplicationName/Default.aspx?Step=3
- ...
【问题讨论】:
我想知道如何在每次点击向导控件的下一步按钮以显示 ActiveStepIndex 时更新我的 URL 的查询字符串。
例子:
【问题讨论】:
真的,当活动步骤在任何情况下发生变化时,您可能都想这样做。
在您的 .aspx 页面中为 OnActiveStepChanged 添加一个处理程序:
<asp:Wizard ID="NewWizard" runat="server" ActiveStepIndex="0" OnActiveStepChanged="Wizard_OnActiveStepChanged">
<WizardSteps>
...
</WizardSteps>
</asp:Wizard>
然后,实现你的处理程序:
protected void Wizard_OnActiveStepChanged(object sender, EventArgs e)
{
Request.QueryString.Set("Step",Convert.ToString(NewWizard.ActiveStepIndex));
}
这应该可以工作,但是我没有测试过这段代码,所以我不能保证它会工作。
【讨论】:
我刚刚发现了如何处理这种情况。
在 HTML 中:
<body id="body" runat="server">
在代码隐藏中:
protected void wizard_OnActiveStepChanged(object sender, EventArgs e)
{
body.Attributes.Add("onload", "document.location.hash = 'Step" + wizard.ActiveStepIndex + "';");
}
【讨论】: