title: ASP.NET Wizard control misbehavinig?
body: <p>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.</p>
  
  <p>However, what appears to happen is that I can control where the wizard goes next from within NextButtonClick only if I <em>change</em> 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.</p>
  
  <p>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</p>
  
  <pre><code>&lt;asp:Wizard ID="Wizard1" runat="server"&gt;
    &lt;WizardSteps&gt;
      &lt;asp:WizardStep ID="WizardStep0" runat="server" Title="Step 0"&gt;
      &lt;/asp:WizardStep&gt;
      &lt;asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1"&gt;
      &lt;/asp:WizardStep&gt;
      &lt;asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2"&gt;
      &lt;/asp:WizardStep&gt;
      &lt;asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3"&gt;
      &lt;/asp:WizardStep&gt;
    &lt;/WizardSteps&gt;
  &lt;/asp:Wizard&gt;
  </code></pre>
  
  <p>I changed the default step IDs and titles to run from 0 rather than 1, since ActiveStepIndex runs from 0.</p>
  
  <p>Then I add this handler in code-behind</p>
  
  <pre><code>Protected Sub Wizard1_NextButtonClick(sender As Object, e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick
    Wizard1.ActiveStepIndex = 1
  End Sub
  </code></pre>
  
  <p>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</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Can anyone explain this behaviour?</p>