Редагувати

Поділитися через


SiteMapProvider.CurrentNode Property

Definition

Gets the SiteMapNode object that represents the currently requested page.

public:
 virtual property System::Web::SiteMapNode ^ CurrentNode { System::Web::SiteMapNode ^ get(); };
public virtual System.Web.SiteMapNode CurrentNode { get; }
member this.CurrentNode : System.Web.SiteMapNode
Public Overridable ReadOnly Property CurrentNode As SiteMapNode

Property Value

A SiteMapNode that represents the currently requested page; otherwise, null, if the SiteMapNode is not found or cannot be returned for the current user.

Examples

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

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

// 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;
  }
}
' Implement the CurrentNode property.
Public Overrides ReadOnly Property CurrentNode() As SiteMapNode
  Get
    Dim currentUrl As String = FindCurrentUrl()
    ' Find the SiteMapNode that represents the current page.
    Dim aCurrentNode As SiteMapNode = FindSiteMapNode(currentUrl)
    Return aCurrentNode
  End Get
End Property

' Implement the RootNode property.
Public Overrides ReadOnly Property RootNode() As SiteMapNode
  Get
    Return aRootNode
  End Get
End Property

Remarks

The SiteMapResolve event is raised before attempting to retrieve a SiteMapNode object, to enable event subscribers to return an instance of the SiteMapNode class. If there are no event subscribers, the SiteMapProvider class calls the FindSiteMapNode method using the current HTTP context to retrieve a SiteMapNode that represents the currently requested page.

If the currently requested page does not correspond with a SiteMapNode, null is returned. If security trimming is enabled and the user is not permitted to access the SiteMapNode, null is returned.

Applies to

See also