Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ASP.NET provides three navigation Web controls for displaying a navigation user interface based on the site's structure defined in a site map: the SiteMapPath, the TreeView, and the Menu. The SiteMapPath control, which is the focus of discussion in this section, displays a breadcrumb, showing the user where in the site he is currently visiting. All three of these controls are available from the Navigation section of the Toolbox (see Figure 19.4). Figure 19.4. The navigation Web controls can be found in the Toolbox under the Navigation label.
To add the SiteMapPath control to an ASP.NET page, simply drag it from the Toolbox onto the page. Take a moment to add the SiteMapPath control to the Default.aspx pages in the root directory, in the Technology folder, and the Computers subfolder. When we view the SiteMapPath in the pages' Design views, the SiteMapPath control shows the layout based on the values in the site map. Figure 19.5 shows the Visual Web Developer Design view for Technology/Computers/Default.aspx. Figure 19.5. The SiteMapPath shows the breadcrumb relative to the current page.
At this point we've successfully added three SiteMapPath controls to our ASP.NET website! That sure was easy. Take a minute to try out these three pages in a browser. The SiteMapPath renders just like in the Design view; clicking the links in the breadcrumb whisks you back to the appropriate section. (Refer to Figure 19.7 to see the SiteMapPath control on Technology/Computers/Default.aspx.) Customizing the SiteMapPath's Appearance
Like most Web controls we've examined throughout this book, the SiteMapPath control has a number of properties that can be used to customize its appearance. These properties can be set manually through the SiteMapPath's properties listed in the Appearances and Styles sections of the Properties window. To understand how these properties affect the rendered appearance of the SiteMapPath, we first need to discuss the components of the SiteMapPath. The SiteMapPath builds up a list of nodes and path separators. A node is a section in the hierarchy, and the path separator is what separates each node. For example, the SiteMapPath in the Technology/Computers/Default.aspx page has three nodes: Home, Technology, and Computers. Each node is separated by a path separator: >, by default. There are three possible types of nodes:
Table 19.1 lists the SiteMapPath's appearance-related properties, along with a brief description of each one. Some of these properties affect the look and feel of the entire SiteMapPath, whereas others affect particular components of the SiteMapPath, such as just the Current Node or just the path separators.
Take a moment to tinker with these properties and note the results in the Design view. If you don't trust your artistic skills, the SiteMapPath contains an Auto Format option, just like the GridView and DetailsView controls we examined back in Hour 15, "Displaying Data with the Data Web Controls." For some assistance in formatting the SiteMapPath, simply click the Auto Format link in the control's smart tag. Figure 19.6 shows the SiteMapPath's Auto Format dialog box, and Figure 19.7 shows the SiteMapPath control in Technology/Computers/Default.aspx after the Colorful Auto Format setting has been applied. Figure 19.6. Let the Auto Format dialog box aid you in specifying the SiteMapPath's appearance.
Figure 19.7. The SiteMapPath control when visiting Technology/Computers/Default.aspx.
|
Категории