The class is an in-memory representation of the navigation structure for a site, which is provided by one or more site map providers. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|CurrentNode||Gets a SiteMapNode control that represents the currently requested page.|
|Enabled||Gets a Boolean value indicating if a site map provider is specified in the Web.config file and if the site map provider is enabled.|
|Provider||Gets the default SiteMapProvider object for the current site map.|
|Providers||Gets a read-only collection of named SiteMapProvider objects that are available to the class.|
|RootNode||Gets a SiteMapNode object that represents the top-level page of the navigation structure for the site.|
Site maps are used in conjunction with the SiteMapDataSource, SiteMapPath, and other controls to render an effective navigation interface for users to navigate a Web site. A object is a component of the ASP.NET site navigation infrastructure that provides access to read-only site map information for page and control developers using navigation and SiteMapDataSource controls. Other components of the ASP.NET site navigation infrastructure include the SiteMapProvider and XmlSiteMapProvider classes, the Web.sitemap file, and the various controls that work with the class, such as the SiteMapPath control, to render content and menus.
The has several functions:
It provides the root node of the site navigation hierarchy (there can be only one root node).
It identifies which site map provider is the principal, or default, provider.
It keeps track of all the provider objects that are used to create the .
Fundamentally, the is a container for a hierarchical collection of SiteMapNode objects. However, the does not maintain the relationships between the nodes; rather, it delegates this to the site map providers. The acts as an interface to the site navigation information (in the form of SiteMapNode objects) that is held by these site map providers. It keeps track of the providers from which it can access site navigation data and exposes its Providers collection. A provider can store its site map information in any way—as long as it extends the SiteMapProvider abstract class, the class can be initialized successfully from it.
The default provider for the class is the XmlSiteMapProvider class, which works with an XML configuration file, Web.sitemap. However, you can write your own SiteMapProvider object, and use it to initialize the site map for your site. For an example of a custom site map provider, see SiteMapProvider.
A default site map configuration is specified that manages the site navigation configuration. You can override this configuration in the Web.config file, should you choose to write your own site map provider.
The class offers only static members for performance and it can be accessed at any time in a given site from a Web Form or Web server control.
This section contains two code examples. The first code example demonstrates how to declare a site map provider in a Web.config file. The second code example demonstrates how to use a object.
<siteMap defaultProvider="MyXmlSiteMapProvider" enabled="true"> <providers> <add name="MyXmlSiteMapProvider" description="The site map provider that reads in the .sitemap XML files." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="my.sitemap" /> </providers> </siteMap>
The following code example demonstrates how to use the object by accessing its static members to display information about the RootNode and CurrentNode properties. Compare it to the output that is rendered by the SiteMapPath control.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2