SiteMapProvider.RootNode Property

Definition

Gets the root SiteMapNode object of the site map data that the current provider represents.

C#
public virtual System.Web.SiteMapNode RootNode { get; }

Property Value

The root SiteMapNode of the current site map data provider. The default implementation performs security trimming on the returned node.

Examples

The following code example demonstrates how to implement the RootNode property in a class that implements the abstract SiteMapProvider class.

This code example is part of a larger example provided for the SiteMapProvider class.

C#
// Implement the CurrentNode property.
public override SiteMapNode CurrentNode
{
  get
  {
    string currentUrl = FindCurrentUrl();
    // Find the SiteMapNode that represents the current page.
    SiteMapNode currentNode = FindSiteMapNode(currentUrl);
    return currentNode;
  }
}

// Implement the RootNode property.
public override SiteMapNode RootNode
{
  get
  {
    return rootNode;
  }
}

Remarks

The default implementation calls the abstract GetRootNodeCore method.

Notes to Inheritors

When overriding the RootNode property in a derived class, be sure that the implementation does not navigate the provider hierarchy, if one exists, to find the absolute root node of the site.

Applies to

Prodotto Versioni
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also