Displays a set of text or image hyperlinks that enable users to more easily navigate a Web site, while taking a minimal amount of page space.
See Also: SiteMapPath Members
In this topic:
The System.Web.UI.WebControls.SiteMapPath control is a site navigation control that reflects data provided by the System.Web.SiteMap object. It provides a space-saving way to easily navigate a site and serves as a point of reference for where the currently displayed page is within a site. This type of control is commonly called a breadcrumb, or eyebrow, because it displays a hierarchical path of hyperlinked page names that provides an escape up the hierarchy of pages from the current location. System.Web.UI.WebControls.SiteMapDataSource. The System.Web.UI.WebControls.SiteMapPath is useful for sites that have deep hierarchical page structures, but where a System.Web.UI.WebControls.TreeView or System.Web.UI.WebControls.Menu might require too much space on a page.
The System.Web.UI.WebControls.SiteMapPath control works directly with your Web site's site map data. If you use it on a page that is not represented in your site map, it will not be displayed. For more information about site maps, see ASP.NET Site Navigation.
The System.Web.UI.WebControls.SiteMapPath is made up of nodes. Each element in the path is called a node and is represented by a System.Web.UI.WebControls.SiteMapNodeItem object. The node that anchors the path and represents the base of the hierarchical tree is called the root node. The node that represents the currently displayed page is the current node. Any other node between the current node and root node is a parent node. The following table describes the three different node types.
root |
A node that anchors a hierarchical set of nodes. |
parent |
A node that has one or more child nodes, but is not the current node. |
current |
A node that represents the currently displayed page. |
Each node displayed by a System.Web.UI.WebControls.SiteMapPath is a System.Web.UI.WebControls.HyperLink or System.Web.UI.WebControls.Literal control that you can apply a template or style to. The templates and styles are applied to nodes according to two rules of precedence:
If a template is defined for a node, it overrides any style defined for the node.
Templates and styles that are specific to types of nodes override general templates and styles defined for all nodes.
The SiteMapPath.NodeStyle and SiteMapPath.NodeTemplate properties are applied to all nodes, regardless of their node type. If both these properties are defined, the SiteMapPath.NodeTemplate takes precedence.
The SiteMapPath.CurrentNodeTemplate and SiteMapPath.CurrentNodeStyle properties are applied to nodes that represent the currently displayed page. If a SiteMapPath.NodeTemplate is defined in addition to the SiteMapPath.CurrentNodeTemplate, it is ignored. If a SiteMapPath.NodeStyle is defined in addition to the SiteMapPath.CurrentNodeStyle, it is merged with the SiteMapPath.CurrentNodeStyle to create a merged style. This merged style uses all the elements of the SiteMapPath.CurrentNodeStyle, plus any additional elements of the SiteMapPath.NodeStyle that do not conflict with the SiteMapPath.CurrentNodeStyle.
The SiteMapPath.RootNodeTemplate and SiteMapPath.RootNodeStyle properties are applied to the node that represents the root of the site navigation hierarchy. If a SiteMapPath.NodeTemplate is defined in addition to the SiteMapPath.RootNodeTemplate, it is ignored. If a SiteMapPath.NodeStyle is defined in addition to the SiteMapPath.RootNodeStyle, it is merged with the SiteMapPath.RootNodeStyle to create a merged style. This merged style uses all the elements of the SiteMapPath.RootNodeStyle, plus any additional elements of the SiteMapPath.NodeStyle that did not conflict with the SiteMapPath.CurrentNodeStyle. Finally, if the currently displayed page is the root page of the site, the SiteMapPath.RootNodeTemplate and SiteMapPath.RootNodeStyle are used instead of the SiteMapPath.CurrentNodeTemplate or SiteMapPath.CurrentNodeStyle.
The System.Web.UI.WebControls.SiteMapPath control uses the site map provider identified by the SiteMapPath.SiteMapProvider property as its data source for site navigation information. If no provider is specified, it uses the default provider for the site, identified in the System.Web.SiteMap.Provider property. Typically, this is an instance of the default site map provider for ASP.NET, the System.Web.XmlSiteMapProvider. If the System.Web.UI.WebControls.SiteMapPath control is used within a site but no site map provider is configured, the control throws an System.Web.HttpException exception.
The System.Web.UI.WebControls.SiteMapPath control also provides events that you can program against. This allows you to run a custom routine whenever an event occurs. The following table lists the events supported by the System.Web.UI.WebControls.SiteMapPath control.
SiteMapPath.ItemCreated |
Occurs when the System.Web.UI.WebControls.SiteMapPath control first creates a System.Web.UI.WebControls.SiteMapNodeItem and associates it with a System.Web.SiteMapNode. |
SiteMapPath.ItemDataBound |
Occurs when a System.Web.UI.WebControls.SiteMapNodeItem is bound to site map data contained by the System.Web.SiteMapNode. |
Classes that derive from System.Web.UI.WebControls.SiteMapPath override the SiteMapPath.InitializeItem(SiteMapNodeItem) method to customize the System.Web.UI.WebControls.SiteMapNodeItem controls contained by the navigation control. For complete control over the way System.Web.UI.WebControls.SiteMapNodeItem objects are created and added to the System.Web.UI.WebControls.SiteMapPath, derived classes override the SiteMapPath.CreateControlHierarchy method.
For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio 2010 and ASP.NET 4 and ASP.NET Controls and Accessibility.
Example
<asp:SiteMapPath AccessKey="string" BackColor="color name|#dddddd" BorderColor="color name|#dddddd" BorderStyle="