Attaching JavaScript to the Cancel Button of Wizard Control

You can make use of the Wizard control template features to add a confirmation message when the "Cancel" button is clicked. Check out the following code:

<asp:Wizard ID="MyWiz" runat="server">
        
    <WizardSteps>
    
    <asp:WizardStep ID="WizardStep1" runat="server" StepType="Finish">
    This 
is start
    
    </asp:WizardStep>
    
    </WizardSteps>    
        
        
    <HeaderTemplate>
            This 
is the header template
    </HeaderTemplate>
    
    <FinishNavigationTemplate>
    <asp:Button ID="Btn_Finish" runat="server" Text="Finish"
    CommandName="MoveComplete" />
    <asp:Button ID="Btn_Cancel" OnClick="Btn_CancelClick"
    runat="server" OnClientClick="return confirm('Are you sure')"
    Text="Cancel" CommandName="Cancel" />

    </FinishNavigationTemplate>
        
    <StartNavigationTemplate>
        So whats up with these templates
    <asp:Button ID="btn_Next" runat="server" CommandName="MoveNext"
    Text="Next" />
    </StartNavigationTemplate>   
   </asp:Wizard>

That is all you need to do!

powered by IMHO 1.3

Print | posted @ Sunday, August 13, 2006 11:22 PM

Twitter