Reputation: 915
I am struggling to understand the behaviour of the ASP.NET Wizard control. I thought that if I defined a handler Wizard1.NextButtonClick, I could control the ActiveStepIndex and determine to which step the Wizard goes next - ASP.NET would not necessarily take me to the next step when Next is pressed.
However, what appears to happen is that I can control where the wizard goes next from within NextButtonClick only if I change the value of ActiveStepIndex. But in one circumstance, I want to stay on the present step. But if I do not change the value of ActiveStepIndex, ASP.NET will take me to the next step, even though I explicitly set the value of ActiveStepIndex, and have defined my own NextButtonClick.
Rather than show my actual problem with attendant baggage, I have built a simple illustration of this. I created a four-step wizard, nothing else in the HTML but a form tag, body tag etc
<asp:Wizard ID="Wizard1" runat="server">
<WizardSteps>
<asp:WizardStep ID="WizardStep0" runat="server" Title="Step 0">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3">
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
I changed the default step IDs and titles to run from 0 rather than 1, since ActiveStepIndex runs from 0.
Then I add this handler in code-behind
Protected Sub Wizard1_NextButtonClick(sender As Object, e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick
Wizard1.ActiveStepIndex = 1
End Sub
In my understanding, I should not be able to reach Step 2 by pressing Next. But I do. To not reach Step 2, I have to do this
Protected Sub Wizard1_NextButtonClick(sender As Object, e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick
Wizard1.ActiveStepIndex = 3
Wizard1.ActiveStepIndex = 1
End Sub
i.e. when ActiveStepIndex is 1 (which is when I can reach Step 2 but don't think I ought to be able to), I deliberately change its value before setting it back to 1.
To add to the intrigue, if I put Wizard1.ActiveStepIndex in the Watch window, it never becomes 2, even though I move to Step 2.
Can anyone explain this behaviour?
Upvotes: 0
Views: 1113