advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Download the code for this article
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Whidbey's New Wizard Control Adds Navigational Power

As Web applications get more complex, the need for multi-page forms has increased as well. Unfortunately, handling multi-page form data and page navigation in a stateless Web application is particularly demanding. To simplify the process, Microsoft has added built-in multi-page form capability to ASP.NET in the Visual Studio "Whidbey" release. Find out how to give Wizard power to your Web applications. 


advertisement
SP.NET v2.0 adds many new concepts and controls beyond those shipped in version 1.1. One of these is the Wizard control, which can simplify your life when you need to implement a "step by step" interface style to capture data. The Wizard provides built-in navigation capability that lets you make logical field groupings for each step in a single aspx page where the process would normally require multiple steps (and complicated logic or multiple pages). The Wizard control uses ViewState (.NET's built-in method for maintaining control values between requests) to handle the data each time the Wizard posts data back to the server, thus reducing your work. Further, you can use customizable templates to tailor the display for each step of the wizard.

Capturing Customer Information
The sample Wizard application captures customer information details such as name, gender, address, and preferred notifications. Typically, the process would require a long input form or several pages. Figure 1 shows a database-table view of the fields the application should capture.

 
Figure 1. Customer Information Relationship Model: The figure shows the relationships between the three database tables used to store customer information for the sample Wizard application.
You can see from Figure 1 that tblCustomer contains basic customer information. It has a one-to-many relationship with the tblAddress table, which stores customer addresses, and with the tblNotifications table, which stores user notification options.

This example should be very familiar to most Web developers. The number of required fields in the tables is sufficient to illustrate the usefulness of the Wizard control. As you build the project, you'll also learn about the ValidationGroup property, which helps validate wizard controls in named groups. The wizard first displays a welcome page; followed by three pages that capture a customer's personal information, address, and notification options. At the end of the input process, users must confirm the input values to commit the data. When the process completes, the application displays a CustomerId value. To implement the sequence, the Wizard control uses a set of predefined templates that you can configure to handle Start, Finish, Complete and the intermediate data-entry steps.

Building a Wizard Application
You need Visual Studio "Whidbey" installed to run the sample application. To install the sample application first execute the sql file to create the database "CustomerWizard." Next, Copy the aspx files to a folder and open them as existing ASP.NET Web sites. Make appropriate changes to the ConnectionString value in the Web.config file so the application can access the database. Save the solution and you're ready to execute.

Author's Note: The sample enclosed was developed using the Whidbey alpha release, so you can expect changes to occur before the final release version. Nonetheless, this article will give you a good feel for the process of using the new Wizard control, even if the details change somewhat before the release version.

If you'd rather build the application as you read through the article, here's how to get started. Create an ASP.NET Website template and drag the Wizard control from the Core tab of the toolbox onto the default.aspx page design surface. The default definition looks as shown below.

 <asp:wizard id="Wizard1" runat="server"
sidebarenabled="true">
<wizardsteps>
<asp:wizardstep title="Step 1">Step 1 Content
</asp:wizardstep>
<asp:wizardstep title="Step 2">Step 2 Content
</asp:wizardstep>
</wizardsteps>
</asp:wizard>

Figure 2 shows how the template appears by default in Visual Studio.

 
Figure 2. Wizard Control's Default Design View. The figure shows how the Wizard control looks when you first drag it onto the design surface in Visual Studio.
You use the <asp:WizardStep> element to declare a step within the Wizard. Table 1 shows other attributes used in the preceding code fragment along with their descriptions.

Table 1. WizardStep Attributes: The table shows the descriptions for the attributes of the <asp:WizardStep> element used in the sample application.

Attribute/Settings


It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement