
- •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

Site Navigation
The Menu1_MenuItemClick event includes the event delegate MenuEventArgs, which allows you to get at both the values of the child and parent elements selected. For this example, both are used and then populated into the Listbox control, as illustrated in Figure 5-27.
Figure 5-27
SiteMap Data Provider
A whole new series of data providers in the form of DataSource controls have been added to ASP.NET 2.0. One of these new DataSource controls now at your disposal, which we looked at earlier in the chapter, is the SiteMapDataSource control. This new DataSource control was developed to work with site maps and the controls that can bind to them.
Some controls don’t need a SiteMapDataSource control in order to bind to the application’s site map (which is typically stored in the web.sitemap file). Earlier in the chapter, you saw this in action when using the SiteMapPath control. This control was able to work with the web.sitemap file directly without the need for this new data provider.
Certain navigation controls, however, such as the TreeView control and the DropDownList control, require an intermediary SiteMapDataSource control to retrieve the site navigation information.
The SiteMapDataSource control is simple to use as demonstrated throughout this chapter. The SiteMapDataSource control in its simplest form is illustrated here:
<asp:SiteMapDataSource ID=”SiteMapDataSource1” Runat=”server” />
In this form, the SiteMapDataSource control simply grabs the info as a tree hierarchy (as consistently demonstrated so far). Be aware that a number of properties do change how the data is displayed in any control that binds to the data output.
SiteMapViewType
The SiteMapViewType property can take one of three available values: Tree, Flat, or Path. Changing this property’s value dramatically changes how the view of the site map data is represented in the control that binds to it. The following table describes each of these values.
165

Chapter 5
Value |
Description |
|
|
Tree |
This is the default setting for the SiteMapViewType property. The value of |
|
Tree assigns the hierarchical site map structure as it is presented in the site |
|
map data file. |
Flat |
This value flattens the hierarchical structure of the data that is presented in |
|
the site map data file so that no hierarchical structure is represented. This is |
|
ideal setting for controls such as the DropDownList control. |
Path |
This value presents the navigation structure that shows the data as a hier- |
|
archical structure from the current node to the root node (this is similar to |
|
how it is presented in the SiteMapPath control). |
|
|
StartingNodeType
The StartingNodeType property sets the depth where the SiteMapDataSource control starts retrieving node objects. It is based on the current node. For example, if you were looking at a page in the hierarchy that contained child nodes and you set the StartingNodeType to Root (which is the default), all the links for the entire hierarchy are displayed. However, if you set the StartingNodeType to Parent, only the parent node to the node being displayed and all the successive child nodes are displayed. Finally, if you set the StartingNodeType to Current, only the current node and any child nodes are shown in the hierarchy. This is demonstrated in Listing 5-25. For this example, use the site map from Listing 5-1 and create a page called Markets.aspx.
Listing 5-25: Changing the StartingNodeType values in Markets.aspx
<%@ Page Language=”VB” %>
<html xmlns=”http://www.w3.org/1999/xhtml” > <head runat=”server”>
<title>SiteMapDataSource</title>
</head>
<body>
<form id=”form1” runat=”server”>
<asp:SiteMapDataSource ID=”SiteMapDataSource1” Runat=”server” SiteMapViewType=”flat” StartingNodeType=”root” /> <asp:BulletedList ID=”BulletedList1” Runat=”server” DisplayMode=”HyperLink” DataSourceId=”SiteMapDataSource1” DataTextField=”Title” DataValueField=”Url” BulletStyle=”Circle” >
</asp:BulletedList>
</form>
</body>
</html>
For this page, the StartingNodeType is set to Root for the bulleted list of site links. This gives you the results illustrated in Figure 5-28.
166

Site Navigation
Figure 5-28
Now simply change the StartingNodeType to Parent, and you get the results illustrated in Figure 5-29.
Figure 5-29
And finally, set the StartingNodeType to Current, and you get the results shown in Figure 5-30.
167