'Wizard popup, when reopening popup pressing previous button sends to first step

I have a popup wizard that defines a student behavior which I have created a save draft button on. When clicking the save draft button it saves the draft to the database. When I load up the draft, I've created code to open up the same page of the wizard. However, when I press the previous button on the draft it doesn't take me to the previous step of the wizard, it goes to the first step of the wizard.

  <asp:Wizard ID="defineBehaviourWizard" runat="server" Width="100%"
            DisplaySideBar="False" DisplayCancelButton="True"
            OnActiveStepChanged="defineBehaviourWizard_ActiveStepChanged"
            OnNextButtonClick="defineBehaviourWizard_NextButtonClick"
            OnFinishButtonClick="defineBehaviourWizard_FinishButtonClick"
            OnCancelButtonClick="defineBehaviourWizard_CancelButtonClick">
            <StartNavigationTemplate>
                <asp:Button ID="nextButton" runat="server" ValidationGroup="dbpValidationGroup" CommandName="MoveNext" CssClass="btn" Text="<%$ Resources:Global, Next %>" />
                <asp:Button ID="cancelButton" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="btn" Text="<%$ Resources:Global, Cancel %>" OnClientClick="return confirmDBPClose();" />
            </StartNavigationTemplate>
            <StepNavigationTemplate>
                <asp:Button ID="saveButton" runat="server" OnClick="defineBehaviourWizard_SaveDraftButtonClick" CausesValidation="False" CssClass="btn" Text="Save For Later" />
                <asp:Button ID="previousButton" runat="server" CausesValidation="False" CommandName="MovePrevious" CssClass="btn" Text="<%$ Resources:Global, Previous %>" />
                <asp:Button ID="nextButton" runat="server" ValidationGroup="dbpValidationGroup" CommandName="MoveNext" CssClass="btn" Text="<%$ Resources:Global, Next %>" />
                <asp:Button ID="cancelButton" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="btn" Text="<%$ Resources:Global, Cancel %>" OnClientClick="return confirmDBPClose();" />
            </StepNavigationTemplate>
            <FinishNavigationTemplate>
                <asp:Button ID="printBehaviorButton" runat="server" CssClass="btn" Text="<%$ Resources:Global, Print %>" Enabled="false" OnClientClick="disablePopupTimer();" OnClick="PrintBehaviorButton_Click" />
                <asp:Button ID="finishPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious" CssClass="btn" Text="<%$ Resources:Global, Previous %>" />
                <asp:Button ID="finishButton" runat="server" CommandName="MoveComplete" CssClass="btn" Text="<%$ Resources:Global, Finish %>" OnClientClick="return showPleaseWait();" />
                <asp:Button ID="cancelButton" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="btn" Text="<%$ Resources:Global, Cancel %>" OnClientClick="return confirmDBPClose();" />
            </FinishNavigationTemplate>
            <WizardSteps>
public void openDraftButton(object sender, EventArgs e, int id)
        {
            //reopens popup wizard on the last saved step of the draft

            var behaviour = CmsService.GetStudentBehaviour(id);
            defineBehaviourPopup.BehaviorId = (id.ToString());
            StudentBehaviourId = id;

           
            //shows popup wizard
            Show();
            
            //makes the behaviourwizard go to the last active step of the draft
            defineBehaviourWizard.ActiveStepIndex = (behaviour.DraftStep);
            
        }

I attempted to place a onclick function for the previous button and this is the function I came up with. But, this doesn't work at all. It still goes to the first step of the wizard when the previous button is pressed. Is there any way to set the index or reset the index of the wizard?

public void previousButtonClick(object sender, EventArgs e)
        {
            //loads the current student behaviour card that the popup wizard is defining 
            var behaviour = CmsService.GetStudentBehaviour((int)StudentBehaviourId);

            //if its a draft, the active step will be minused by one when this previous button is pressed
            if (behaviour.Draft)
            {

                if (defineBehaviourWizard.ActiveStepIndex == behaviour.DraftStep)
                {

                    defineBehaviourWizard.ActiveStepIndex = (behaviour.DraftStep - 1);
                }

            }
            
        }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source