O'Reilly logo

ASP.NET 2.0 Cookbook, 2nd Edition by Geoffrey T. LeBlond, Michael A Kittel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

21.9. Adding Breadcrumbs

Problem

You want to use a dynamic menu in your application and display a breadcrumb trail to show the current location within the application and to provide an easy way for the user to navigate back to a previous location.

Solution

Implement the dynamic menu solution described in Recipe 21.8 and add a SiteMapPath control to the .master file. Use the .master file as the master page for all pages in your application that require the dynamic menu and the breadcrumb trail.

Example 21-24 shows the .master file used to display the dynamic menu and breadcrumb trail. Figure 21-9 shows the output a sample page with the breadcrumb trail displayed.

Sample page with dynamic menu and breadcrumb trail

Figure 21-9. Sample page with dynamic menu and breadcrumb trail

Discussion

To improve the user experience, applications commonly display a breadcrumb trail to show the current location within the application and to provide an easy way to navigate back to a previous location. The site navigation infrastructure provided in ASP.NET 2.0 can be used to display a breadcrumb trail using the data in the Web.sitemap file that is also used to as the data source for dynamic menus (see Recipe 21.8).

Once you have the site structure defined in the Web.sitemap file, as described in Recipe 21.8, all that is required is to add a SiteMapPath control to the .master file that will be used as the master page for your application pages that need to display ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required