[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 952
  • Last Modified:

How to identify what my StepIndex is on .net wizard control

I have a .NET wizard with 14 steps total.  On the first step, it asks a question that decides what step they will go to next.  Basically, if they check one box, they go to the next step; if they check the other one; it skips the next step and sends them right on to the 3rd one.  

I never have been really sure on how to determine the step index.  Its not an option in properties.  In the WizardStep Collection editor, there is a number next to each step, but i'm not sure if that's the Index, either.

Here's my code for the first step:

    'COMPANY QUESTION
    Protected Sub SetupWorksheet_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles SetupWorksheet.NextButtonClick
        If SetupWorksheet.ActiveStepIndex = 0 Then
            If rdoNoRec.Checked Then
                'Send them directly to the Practice information step
                SetupWorksheet.ActiveStepIndex = 2
            Else
                SetupWorksheet.ActiveStepIndex = 1
            End If
        End If
    End Sub


This works great.  I've tried it both ways, and it sends me to the correct step.  

HOWEVER, i have 8 steps that are optional.  That is, they fill out the first of the 8, and they can either go on to the next step (add another item) or they can go directly to finish.  In order to do this, they check a box that says "if you are done, check this box" (something like that).  

Here's the code I am trying to use here:

    Protected Sub chkfinishA_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkfinishA.CheckedChanged
        If chkfinishA.Checked = True Then
            SetupWorksheet.ActiveStepIndex = 11
        End If
    End Sub

The problem here is that if I tell it to go to ActiveStepIndex 11, it brings you to the step DIRECTLY BEFORE the one I want (the step where i have "Review what you have entered").  
So, naturally, I figured the Index of my review step MUST be 12.  Nope... When I use 12, it brings you to the step DIRECTLY AFTER the my Review step..

I'm basically stumped here.  Its like I'm working with a "phantom" WizardStep!!!!!!!!!  Is there an 11.5??? haha!

Thanks for any help Experts!
0
georgem767
Asked:
georgem767
  • 5
  • 4
1 Solution
 
TSmoothCommented:
Instead of using the index numbers directly which can make things difficult when you modify the order of steps, use the wizard control's "WizardSteps.IndexOf" method along with the id of the step. This might also solve your problem. Example (Assumes you have a wizard step with the id "WizardStep3":

If (Me.CheckBox1.Checked) Then
        Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(Me.WizardStep3)
      End If

Open in new window

0
 
georgem767Author Commented:
TSmooth:

I tried using your code, and when I check the box, I get the following message:

[InvalidOperationException: The command 'MoveNext' is not valid for the previous step, make sure the step type is not changed between postbacks.  I never clicked the previous button or back or anything; I went into it fresh.  It moves on to the next step if I don't check the box...
If (Me.chkfinishA.Checked) Then
  SetupWorksheet.ActiveStepIndex = SetupWorksheet.WizardSteps.IndexOf(Me.Review)
End If

Open in new window

0
 
TSmoothCommented:
What is the step type of the Me.Review step?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
georgem767Author Commented:
It is set to Auto.
0
 
georgem767Author Commented:
I found out that it works if the step type is "step".  Not if it's complete or finish.  hmph....
0
 
TSmoothCommented:
I think the complete or finish steps need to be the last two steps so if you just change the order of the steps in the wizard control and adjust your movement using the methods discussed in this question then that should solve your problems.
0
 
georgem767Author Commented:
Okay, I added one more step after the Review step.  I thought if I did that, i could leave the review steptype=step, and have the next one the "finished" step.  well, now that i've done that (i maintained the indexof function) now it sends me to that last step i created.  

when i redirect it to another step is is automatically clicking the next button on that step or something???

I noticed before I changed my code, when it sent me to the wrong step, all the validations lit up as if I had hit the next button, even though i didnt.

today is turning out to be a very tiring day...
0
 
TSmoothCommented:
It really sounds like something in your code somewhere is forcing the click of a next button or the call of MoveNext(). Can you paste more of your code or search thoroughly for something like this happening? You could set a debug breakpoint on the button click of the next button on the step that is supposed to send you to a different step if the check box is checked and then once that breakpoint is hit, step through the code to see what is happening that is screwing up the order or causing the error.
0
 
TSmoothCommented:
Did you find what was causing it to advance?
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now