The SiteMapPath displays a navigation path (which is also known as a breadcrumb or eyebrow) that shows the user the current page location and displays links as a path back to the home page. The control provides many options for customizing the appearance of the links.
Drag the SiteMapPath control from the Toolbox panel to your page.
The SiteMapPath control obtains navigation data from a site map. This data includes information about the pages in your site, such as the URL, title, description, and location in the navigation hierarchy. Storing your navigation data in one place makes it easier to add and remove items in the navigational menus of your site. For more information about site maps, see ASP.NET Site Maps in the MSDN library.
The simplest way to create a site map is to create an XML file named Web.sitemap that organizes the pages in the site hierarchically. This site map is automatically picked up by the default site-map provider for ASP.NET. The Web.sitemap file must be located in the application root directory.
Only pages that are listed in the site map can display navigation data in the SiteMapPath control. If you place a SiteMapPath control on a page that is not listed in the site map, the control will display nothing to the client.
A simple sitemap in a Web.sitemap file might look something like this:
<siteMap> <siteMapNode title="Home" description="Home" url="~/default.aspx" > <siteMapNode title="Services" description="Services we offer" url="~/Services.aspx"> <siteMapNode title="Training" description="Training classes" url="~/Training.aspx" /> <siteMapNode title="Consulting" description="Consulting services" url="~/Consulting.aspx" /> </siteMapNode> </siteMapNode> </siteMap>
In Design view, right-click the Login control, and then click Show Common Control Tasks.
You can also click the Login control in Design view, click the arrow in the upper-right corner to show the Common Login Tasks menu. Click the arrow again to hide the menu.
On the Common SiteMapPath Tasks menu, click AutoFormat.
In the AutoFormat dialog box, select one of the schemes in the Select a scheme list. The effect of the scheme on your SiteMapPath control is displayed in the Preview area.
Click OK to apply the formatting scheme and close the dialog, or Apply to apply the formatting scheme without closing the dialog.
You can also interactively format the SiteMapPath control, apply styles and change the text.
For a full description of all SiteMapPath control properties, see SiteMapPath in the MSDN library.
The SiteMapPath is composed of various template regions. You can also interactively design these.
In Design view, right-click the SiteMapPath control, and then click Show Common Control Tasks.
On the Common SiteMapPath Tasks menu, click Edit Templates. This switches the Wizard into Template Editing Mode.
In the Display dropdown, select the template you would like to edit.
Add text or controls or make changes to the Template.
When you are finished designing your templates, on the Common SiteMapPath Tasks menu, click End Template Editing to return to the standard SiteMapPath design mode.
The SiteMapPath control allows users to navigate backward—from the current page to pages that are higher in the site hierarchy. However, the SiteMapPath control does not allow you to navigate forward—from the current page to another page that is lower in the site hierarchy. For example, you can use the SiteMapPath control in newsgroup or message board applications to allow users to see the path to the article that they are currently browsing.
You can use the SiteMapPath control to create site navigation without code and without binding data. The control can read and render the site-map information automatically. However, if needed, you can also use the SiteMapPath control to alter site-map data. For more information, see How to: Programmatically Modify Site-Map Nodes in Memory in the MSDN library.