Displaying a Wizard


The Wizard control, like the MultiView control, can be used to divide a large form into multiple sub-forms. The Wizard control, however, supports many advanced features that are not supported by the MultiView control.

The Wizard control contains one or more WizardStep child controls. Only one WizardStep is displayed at a time.

The Wizard control supports the following properties (this is not a complete list):

  • ActiveStepEnables you to retrieve the active WizardStep control.

  • ActiveStepIndexEnables you to set or get the index of the active WizardStep control.

  • CancelDestinationPageUrlEnables you to specify the URL where the user is sent when the Cancel button is clicked.

  • DisplayCancelButtonEnables you to hide or display the Cancel button.

  • DisplaySideBarEnables you to hide or display the Wizard control's side bar. The side bar displays a list of all the wizard steps.

  • FinishDestinationPageUrlEnables you to specify the URL where the user is sent when the Finish button is clicked.

  • HeaderTextEnables you to specify the header text that appears at the top of the Wizard control.

  • WizardStepsEnables you to retrieve the WizardStep controls contained in the Wizard control.

The Wizard control also supports the following templates:

  • FinishNavigationTemplateEnables you to control the appearance of the navigation area of the finish step.

  • HeaderTemplateEnables you control the appearance of the header area of the Wizard control.

  • SideBarTemplateEnables you to control the appearance of the side bar area of the Wizard control.

  • StartNavigationTemplateEnables you to control the appearance of the navigation area of the start step.

  • StepNavigationTemplateEnables you to control the appearance of the navigation area of steps that are not start, finish, or complete steps.

The Wizard control also supports the following methods:

  • GetHistory()Enables you to retrieve the collection of WizardStep controls that have been accessed.

  • GetStepType()Enables you to return the type of WizardStep at a particular index. Possible values are Auto, Complete, Finish, Start, and Step.

  • MoveTo()Enables you to move to a particular WizardStep.

The Wizard control also supports the following events:

  • ActiveStepChangedRaised when a new WizardStep becomes the active step.

  • CancelButtonClickRaised when the Cancel button is clicked.

  • FinishButtonClickRaised when the Finish button is clicked.

  • NextButtonClickRaised when the Next button is clicked.

  • PreviousButtonClickRaised when the Previous button is clicked.

  • SideBarButtonClickRaised when a side bar button is clicked.

A Wizard control contains one or more WizardStep controls that represent steps in the wizard. The WizardStep control supports the following properties:

  • AllowReturnEnables you to prevent or allow a user to return to this step from a future step.

  • NameEnables you to return the name of the WizardStep control.

  • StepTypeEnables you to get or set the type of wizard step. Possible values are Auto, Complete, Finish, Start and Step.

  • TitleEnables you to get or set the title of the WizardStep. The title is displayed in the wizard side bar.

  • WizardEnables you to retrieve the Wizard control containing the WizardStep.

The WizardStep also supports the following two events:

  • ActivateRaised when a WizardStep becomes active.

  • DeactivateRaised when another WizardStep becomes active.

The StepType property is the most important property. This property determines how a WizardStep is rendered. The default value of StepType is Auto. When StepType is set to the value Auto, the position of the WizardStep in the WizardSteps collection determines how the WizardStep is rendered.

You can explicitly set the StepType property to a particular value. If you set StepType to the value Start, then a Previous button is not rendered. If you set the StepType to Step, then both Previous and Next buttons are rendered. If you set StepType to the value Finish, then Previous and Finish buttons are rendered. Finally, when StepType is set to the value Complete, no buttons are rendered.

The page in Listing 4.19 illustrates how you can use a Wizard control to display a multiple part form (see Figure 4.11).

Figure 4.11. Displaying a wizard with the Wizard control.


Listing 4.19. ShowWizard.aspx

[View full width]

<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR /xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">     Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As  WizardNavigationEventArgs)         lblSSNResult.Text = txtSSN.Text         lblPhoneResult.Text = txtPhone.Text     End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head  runat="server">     <style type="text/css">         .wizard         {             border:solid 1px black;             font:14px Verdana,Sans-Serif;             width:400px;             height:300px;         }         .header         {             color:gray;             font:bold 18px Verdana,Sans-Serif;         }         .sideBar         {             background-color:#eeeeee;             padding:10px;             width:100px;         }         .sideBar a         {             text-decoration:none;         }         .step         {             padding:10px;         }     </style>     <title>Show Wizard</title> </head> <body>     <form  runat="server">     <div>     <asp:Wizard                  HeaderText="Product Survey"         OnFinishButtonClick="Wizard1_FinishButtonClick"         Css         HeaderStyle-Css         SideBarStyle-Css         StepStyle-Css         Runat="server">         <WizardSteps>         <asp:WizardStep  Title="Introduction">         Please complete our survey so that we can improve our         products.         </asp:WizardStep>         <asp:WizardStep  Title="Step 1">         <asp:Label                          Text="Social Security Number:"             AssociatedControl             Runat="server" />         <br />         <asp:TextBox                          Runat="server" />         </asp:WizardStep>         <asp:WizardStep  Title="Step 2" StepType="Finish">         <asp:Label                          Text="Phone Number:"             AssociatedControl             Runat="server" />         <br />         <asp:TextBox                          Runat="server" />         </asp:WizardStep>         <asp:WizardStep  Title="Summary" StepType="Complete">         <h1>Summary</h1>         Social Security Number:         <asp:Label                          Runat="server" />         <br /><br />         Phone Number:         <asp:Label                          Runat="server" />         </asp:WizardStep>         </WizardSteps>     </asp:Wizard>     </div>     </form> </body> </html> 

The Wizard control in Listing 4.19 contains four WizardStep controls. Notice that the StepType property is explicitly set for the last two WizardStep controls. When the Finish WizardStep is rendered, a Finish button is rendered. When the Complete WizardStep is rendered, no buttons are rendered.

The Wizard control's FinishButtonClick event is handled with a method named Wizard1_FinishButtonClick(). This method updates the final WizardStep with a summary of the answers entered in the previous WizardStep controls.




ASP. NET 2.0 Unleashed
ASP.NET 2.0 Unleashed
ISBN: 0672328232
EAN: 2147483647
Year: 2006
Pages: 276

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net