- •Contents
- •Introduction
- •Acknowledgments
- •The Goals of ASP.NET 2.0
- •Developer productivity
- •Administration and management
- •Performance and scalability
- •Device-specific code generation
- •Additional New Features of ASP.NET 2.0
- •New developer infrastructures
- •New compilation system
- •Additions to the page framework
- •New objects for accessing data
- •New server controls
- •A New IDE for Building ASP.NET 2.0 Pages
- •The Document Window
- •Views in the Document Window
- •The tag navigator
- •Page tabs
- •Code change status notifications
- •Error notifications and assistance
- •The Toolbox
- •The Solution Explorer
- •Lost Windows
- •Other Common Visual Studio Activities
- •Creating new projects
- •Making references to other objects
- •Using smart tags
- •Saving and importing Visual Studio settings
- •Application Location Options
- •Built-in Web server
- •Web site requiring FrontPage Extensions
- •The ASP.NET Page Structure Options
- •Inline coding
- •New code-behind model
- •New Page Directives
- •New attributes
- •New directives
- •New Page Events
- •Cross-Page Posting
- •New Application Folders
- •\Code folder
- •\Themes folder
- •\Resources folder
- •Compilation
- •The New Data Source Controls
- •The SqlDataSource and GridView Controls
- •Reading data
- •Applying paging in the GridView
- •Sorting rows in the GridView control
- •Defining bound columns in the GridView control
- •Enabling the editing of rows in the GridView control
- •Deleting data from the GridView
- •Dealing with other column types in the GridView
- •Selecting which fields to display in the DetailsView control
- •Using the GridView and DetailsView together
- •Updating, inserting, and deleting rows
- •XmlDataSource Control
- •ObjectDataSource Control
- •SiteMapDataSource Control
- •DataSetDataSource Control
- •Visual Studio 2005
- •Connection Strings
- •Site Maps
- •The PathSeparator property
- •The PathDirection property
- •The ParentLevelsDisplayed property
- •The ShowToolTips property
- •Examining the parts of the TreeView control
- •Binding the TreeView control to an XML file
- •Selecting multiple options in a TreeView
- •Specifying custom icons in the TreeView control
- •Specifying lines used to connect nodes
- •Working with the TreeView control programmatically
- •Applying different styles to the Menu control
- •Menu Events
- •Binding the Menu control to an XML file
- •SiteMap Data Provider
- •SiteMapViewType
- •StartingNodeType
- •SiteMap API
- •Why Do You Need Master Pages?
- •The Basics of Master Pages
- •Coding a Master Page
- •Coding a Content Page
- •Mixing page types and languages
- •Specifying which master page to use
- •Working with the page title
- •Working with controls and properties from the master page
- •Nesting Master Pages
- •Container-Specific Master Pages
- •Event Ordering
- •Caching with Master Pages
- •Using ASP.NET 2.0 Packaged Themes
- •Applying a theme to a single ASP.NET page
- •Applying a theme to an entire application
- •Applying a theme to all applications on a server
- •Removing themes from server controls
- •Removing themes from Web pages
- •Removing themes from applications
- •Creating Your Own Themes
- •Creating the proper folder structure
- •Creating a skin
- •Including CSS files in your themes
- •Having your themes include images
- •Defining Multiple Skin Options
- •Programmatically Working with Themes
- •Themes and Custom Controls
- •Authentication
- •Authorization
- •ASP.NET 2.0 Authentication
- •Setting up your Web site for membership
- •Adding users
- •Asking for credentials
- •Working with authenticated users
- •Showing the number of users online
- •Dealing with passwords
- •ASP.NET 2.0 Authorization
- •Using the LoginView server control
- •Setting up your Web site for role management
- •Adding and retrieving application roles
- •Deleting roles
- •Adding users to roles
- •Getting all the users of a particular role
- •Getting all the roles of a particular user
- •Removing users from roles
- •Checking users in roles
- •Using the Web Site Administration Tool
- •The Personalization Model
- •Adding a simple personalization property
- •Using personalization properties
- •Adding a group of personalization properties
- •Using grouped personalization properties
- •Defining types for personalization properties
- •Using custom types
- •Providing default values
- •Making personalization properties read-only
- •Anonymous Personalization
- •Enabling anonymous identification of the end user
- •Working with anonymous identification events
- •Anonymous options for personalization properties
- •Migrating Anonymous Users
- •Personalization Providers
- •Working with the Access personalization provider
- •Working with the SQL Server personalization provider
- •Using multiple providers
- •Building Dynamic and Modular Web Sites
- •Introducing the WebPartManager control
- •Working with zone layouts
- •Understanding the WebPartZone control
- •Explaining the WebPartPageMenu control
- •Modifying zones
- •Caching in ASP.NET 1.0/1.1
- •Output caching
- •Partial page caching
- •Data caching using the Cache object
- •Cache dependencies
- •ASP.NET 2.0 unseals the CacheDependency class
- •Enabling databases for SQL Server cache invalidation
- •Enabling tables for SQL Server cache invalidation
- •Looking at SQL Server
- •Looking at the tables that are enabled
- •Disabling a table for SQL Server cache invalidation
- •Disabling a database for SQL Server cache invalidation
- •Configuring your ASP.NET Application
- •Adding more than one table to a page
- •Attaching SQL Server cache dependencies to the Request object
- •Attaching SQL Server cache dependencies to the Cache object
- •Customizing the side navigation
- •Examining the AllowReturn attribute
- •Working with the StepType attribute
- •Adding a header to the Wizard control
- •Utilizing Wizard control events
- •Working with images from disk
- •Resizing images
- •Displaying images from streams
- •The MMC ASP.NET Snap-In
- •General
- •Custom Errors
- •Authorization
- •Authentication
- •Application
- •State Management
- •Advanced
- •ASP.NET Web Site Administration Tool
- •Home
- •Security
- •Profile
- •Application
- •Provider
- •Managing the Site Counter System
- •Generics
- •Iterators
- •Anonymous Methods
- •Operator Overloading
- •Visual Basic XML Documentation
- •New Visual Basic Keywords
- •Continue
- •Using
- •Global
- •Index
Additional New Controls
Customizing the side navigation
From the example in Figure 12-8, you can see that the steps are defined as Step 1, Step 2, and Step 3. The links are created based upon the Title property’s value that you give to each of the <asp:WizardStep> elements in the Wizard control:
<asp:WizardStep Runat=”server” Title=”Step 1”> This is the first step.</asp:WizardStep>
By default, when creating Wizard Steps in Design view, each Wizard Step created is titled Step X (with X being the number in the sequence). You can easily change the value of the Title attributes of each of the Wizard Steps to define the steps as you see fit. Figure 12-9 shows the side navigation of the Wizard control with renamed titles.
Figure 12-9
Examining the AllowReturn attribute
Some other interesting points of customization for the side navigation piece of the Wizard control include the AllowReturn attribute. By setting this attribute on one of the Wizard Steps to False, you can remove the capability for the end users to go back to the step after they have viewed it. This ensures that the end user cannot backward navigate to any of the viewed steps that contained this attribute, but he would be able to return to any steps that do not contain this attribute or which have this attribute set to True:
<asp:WizardStep Runat=”server” Title=”Step 1” AllowReturn=”False”> This is the first step.</asp:WizardStep>
Working with the StepType attribute
Another interesting attribute in the <asp:WizardStep> element is the StepType attribute. The StepType attribute defines the structure of the buttons used on the steps. For instance, by default, the Wizard control places only a Next button on the first step. It understands that because this is the first step, you probably don’t need the Previous button here. It also knows to use a Next and Previous button on the middle step, but it uses a Previous and a Finish button on the last step. It draws the buttons in this fashion because, by default, the StepType attribute is set to Auto, meaning that the Wizard control determines the placement
357
Chapter 12
of buttons. You can, however, take control of the StepType attribute in the <asp:WizardStep> element to make your own determination about which buttons are used for which steps.
Besides a StepType value of Auto, the other options include Start, Step, Finish, and Complete. A value of Start for the Wizard Step means that the step defined has only a Next button and nothing else. This simply allows the user to proceed to the next step in the series. A value of Step means that the Wizard Step has a Next and a Previous button. A value of Finish means that the step includes a Previous and a Finish button. The last one, Complete, is an interesting step that you can add to give some final message to the end user who is working through the steps of your Wizard control. In the Wizard control shown in Listing 12-8, for example, when the end user gets to the last step and clicks the Finish button, nothing happens and the user just stays on the last page. You can address this by adding a final step to the collection of Wizard Steps to give a final message as shown in Listing 12-9.
Listing 12-9: Having a Complete step in the Wizard Step collection
<WizardSteps>
<asp:WizardStep Runat=”server” Title=”Step 1”> This is the first step.</asp:WizardStep> <asp:WizardStep Runat=”server” Title=”Step 2”> This is the second step.</asp:WizardStep> <asp:WizardStep Runat=”server” Title=”Step 3”> This is the third and final step.</asp:WizardStep>
<asp:WizardStep Runat=”server” Title=”Final Step” StepType=”Complete”>
Thanks for working through the steps.</asp:WizardStep> </WizardSteps>
When you run this Wizard control in a page, you still only see the first three steps in the side navigation. Because the last step has a StepType set to Complete, it does not appear in the side navigation list, and when the end user clicks the Finish button in Step 3, the last step — Final Step — is shown and no buttons are shown with it.
Adding a header to the Wizard control
The Wizard control enables you to place a header at the top of the control with the use of the HeaderText attribute in the main <asp:Wizard> element. This is illustrated in Listing 12-10.
Listing 12-10: Working with the HeaderText attribute
<asp:Wizard ID=”Wizard1” Runat=”server” SideBarEnabled=”true” ActiveStepIndex=”0” HeaderText=” Step by Step with the Wizard control ” HeaderStyle-BackColor=”DarkGray” HeaderStyle-Font-Bold=”true” HeaderStyle-Font-Size=”20”>
...
</asp:Wizard>
This code creates a header that appears on each of the steps in the Wizard. The result of this snippet is shown in Figure 12-10.
358
Additional New Controls
Figure 12-10
Working with the Wizard’s navigation system
As I stated earlier, the Wizard control allows for a very high degree of customization — especially in the area of style. You can customize every single aspect of the process, as well as how every element appears to the end user.
Pay particular attention to the options that are available for customization of the navigation buttons. By default, the Wizard Steps use buttons for Next, Previous, and Finish that are used throughout the entire series of steps. From the main <asp:Wizard> element, you can change everything about these buttons and how they work.
First, if you look through the long list of attributes available for this element, notice that one available button isn’t shown by default. The Cancel button can be added by setting the value of the DisplayCancelButton attribute to True. As shown in Figure 12-11, this gives you a Cancel button within the navigation created for each and every step (including the final step in the series).
Figure 12-11
359
Chapter 12
After you decide which buttons to use within the Wizard navigation, you can choose the style of these buttons. By default, regular buttons appear, but you can change the button style with the CancelButtonType,
FinishStepButtonType, FinishStepPreviousButtonType, NextStepButtonType, PreviousStepButtonType, and StartStepNextButtonType attributes. All these attributes change the style of the buttons used for the navigation system of the Wizard control. If you use any of these button types and want all the buttons consistently styled, you must change each attribute to the same value. The possible values of these button-specific elements include Button, Image, and Link. Button is the default and means that the navigation system uses buttons. A value of Image enables you to use image buttons, and Link turns a selected item in the navigation system into a hyperlink.
In addition to these button-specific attributes of the <asp:Wizard> element, you can also specify a URL to which the user is directed when the he clicks either the Cancel or Finish buttons. To redirect the user with one of these buttons, you use the CancelDestinationPageUrl or the FinishDestinationPageUrl attributes and set the appropriate URL as the destination.
Finally, you are not required to use the default text included with the buttons in the navigation system. You can change the text of each of the buttons with the use of the CancelButtonText,
FinishStepButtonText, FinishStepPreviousButtonText, NextStepButtonText,
PreviousStepButtonText, and the StartStepNextButtonText attributes.
Utilizing Wizard control events
One of the most convenient capabilities of the Wizard control is that it enables you to divide large forms into logical pieces. The end user can then work step by step through each section of the form. The developer, dealing with the inputted values of the form, has a few options because of the various events that are available in the Wizard control.
The Wizard control exposes events for each of the possible steps that an end user might take when working with the control. The following table describes each of the available events.
Event |
Description |
|
|
ActiveViewChanged |
Triggers when the end user moves from one step to the next. |
|
It doesn’t matter if the step is the middle or final step in the |
|
series. This event simply covers each step change generically. |
CancelButtonClick |
Triggers when the end user clicks the Cancel button in the |
|
navigation system. |
FinishButtonClick |
Triggers when the end user clicks the Finish button in the |
|
navigation system. |
NextButtonClick |
Triggers when the end user clicks the Next button in the |
|
navigation system. |
PreviousButtonClick |
Triggers when the end user clicks the Previous button in the |
|
navigation system. |
SideBarButtonClick |
Triggers when the end user clicks one of the links contained |
|
within the sidebar navigation of the Wizard control. |
|
|
360
