Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

SiteMapPath Web Server Control Overview

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.

This topic contains:

The SiteMapPath control obtains navigation data from a site map. This data includes information about the pages in your Web site, such as the URL, title, description, and location in the navigation hierarchy. Storing navigation data in one place makes it easier to add and remove items in the navigational menus of a Web site.

The following code example shows site-map data that is included in a Web.sitemap file.

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

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.

You can add a SiteMapPath control to the Training.aspx page by adding the following code.

<asp:SiteMapPath ID="SiteMapPath1" Runat="server"></asp:SiteMapPath>

When the Training.aspx page is viewed in the browser, the SiteMapPath control displays something like the following, with Home and Services rendered as hyperlinks:

        Home > Services > Training

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.

The SiteMapPath control enables users to navigate backward — from the current page to pages that are higher in the site hierarchy. However, the SiteMapPath control does not enable users 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 enable users to see the path to the article that they are currently browsing.

The following table lists the classes that relate to the SiteMapPath control.

Member

Description

SiteMapPath

The main class for the control.

Back to top

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.