Determine Previous WizardStep using Wizard’s GetHistory Method

Recently I was working on a project that contained an ASP.NET Wizard Control. The control was configured to allow non-linear progression through the WizardSteps. I realized that I needed to know which step the user had been on previously, as that would determine which control would have focus in the current step.

So I Googled, and was able to find out that I could use the Wizard Control’s GetHistory method to find the previous step. GetHistory returns a collection of the WizardStepBase objects that have been accessed, arranged in the order that they were accessed – the first object in the collection is the WizardStep that was accessed last, the next is the WizardStep that was accessed second-to-last, etc.

OK, so far, so good. But the MSDN documentation didn’t include an example of how to use the GetHistory method, and neither did the couple other mentions I found in other articles – they all said you could do it, but they didn’t say how.

So I played around, and figured out a way to use the GetHistory method to get what I needed. Anyone who knows of a smoother or more elegant way, please feel free to post it – I just thought there should be at least one example out there:-)


Dim steps As ArrayList
Dim stp As WizardStep

'get WizardSteps history collection
steps = CType(Me.wzDataEntry.GetHistory, ArrayList)

'if any wizard steps have been previously accessed...
If steps.Count > 0 Then

'get last wizard step
stp = CType(steps.Item(0), WizardStep)

'if last step was 'Project Info', set focus on region dropdownlist
If stp.ID = "stpProjectInfo" Then
End If

End If