7.2. Using the Navigation Controls

ASP.NET 3.5 offers three useful navigation tools: SiteMapPath, Menu, and TreeView. Figure 7-3 shows basic examples of the three navigation controls, without any styling applied.

The SiteMapPath on the left shows the user the path to the current page. This helps if users want to go up one or more levels in the site hierarchy. It also helps them to understand where they are. The TreeView can display the structure of your site and allows you to expand and collapse the different nodes; in Figure 7-3 the entire tree is expanded. When the page first loads, the Menu on the right only displays Home. However, as soon as you move the mouse over it, a submenu will appear showing the child nodes of the Home page element. In Figure 7-3 one of these child elements is the Reviews item, which in turn has child elements itself.

Figure 7-3. Figure 7-3

7.2.1. Architecture of the Navigation Controls

To make it easy to show relevant pages in your site using a Menu, a TreeView, or a SiteMapPath, ASP.NET uses an XML-based file that describes the logical structure of your web site. By default, this file is called Web.sitemap. This file is then used by the navigation controls in your site to present relevant links in an organized way. Simply by hooking up one of the navigation controls to the Web.sitemap file you can create complex user interface elements like fold-out ...

Get Beginning ASP.NET 3.5: In C# and VB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.