Wizard Control not starting on step 1?

December 4, 2009

I quite often make use of the Wizard control – Its very flexible, works well and saves me loads of donkey work to get the desired functionality.

One thing that seems to trip me up, is viewing the individual wizard steps within Visual Studio (Design mode). I view/work on a specific step, perhaps change some code, compile, run it and Wham! Where did step 1 go? I’m now starting at step 3!!

Why? When you save a webform that contains a Wizard control in Visual Studio, the step you are editing is set as the ActiveStep, for example, view step 3 in desaign mode, then save your page and the declarative code for the Wizard will look like this:
(Note that ActiveStepIndex=”3″)

<asp:Wizard ID="WizardRegistration" runat="server" DisplaySideBar="False"
ActiveStepIndex="3" >

I’m not really sure why Visual Studio does this, seems a bit odd to me – The fix?
1) Always remember return to step 1 on your wizard before you save
2) Add the following code, which will ensure that your Wizard always starts at step 1: (My preferred method)

protected void Page_Load(object sender, EventArgs e) {
    if (!IsPostBack) {
        // Set registration wizard to first step
        WizardRegistration.ActiveStepIndex = 0;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: