views:

26

answers:

3

I'm wondering how I could update the querystring of my URL each time I hit the Next button of a Wizard control in order to show the ActiveStepIndex.

Example:

  • http ://ApplicationName/Default.aspx?Step=1
  • http ://ApplicationName/Default.aspx?Step=2
  • http ://ApplicationName/Default.aspx?Step=3
  • ...
A: 

Really you probably want to do this when the Active Step changes under any circumstances.

Add a handler for OnActiveStepChanged in your .aspx page:

    <asp:Wizard ID="NewWizard" runat="server" ActiveStepIndex="0" OnActiveStepChanged="Wizard_OnActiveStepChanged">
    <WizardSteps>
     ...
    </WizardSteps>
   </asp:Wizard>

Then, implement your handler:

protected void Wizard_OnActiveStepChanged(object sender, EventArgs e)
{
  Request.QueryString.Set("Step",Convert.ToString(NewWizard.ActiveStepIndex));
}

This should work, however I haven't tested this code so I cannot make any kind of guarantee that it will work.

Brian Driscoll
It complaints about Request.QueryString saying: "Collection is read-only."
Microcontroleur
A: 

It complaints about Request.QueryString saying: "Collection is read-only."

Microcontroleur
A: 

I just found out how to handle this situation.

In HTML:

<body id="body" runat="server">

In code-behind:

protected void wizard_OnActiveStepChanged(object sender, EventArgs e)
{
    body.Attributes.Add("onload", "document.location.hash = 'Step" + wizard.ActiveStepIndex + "';");
}
Microcontroleur