SiteMapProvider.CurrentNode 屬性

定義

取得代表目前所要求頁面的 SiteMapNode 物件。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

屬性值

SiteMapNode

表示目前所要求之網頁的 SiteMapNode,但如果找不到 SiteMapNode 或無法為目前使用者傳回,則為 nullA SiteMapNode that represents the currently requested page; otherwise, null, if the SiteMapNode is not found or cannot be returned for the current user.

範例

下列程式碼範例示範如何 CurrentNode 在實抽象類別的類別中執行屬性 SiteMapProviderThe following code example demonstrates how to implement the CurrentNode property in a class that implements the abstract SiteMapProvider class.

這個程式碼範例是針對類別提供之較大範例的一部分 SiteMapProviderThis 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

備註

SiteMapResolve 嘗試抓取物件之前引發事件 SiteMapNode ,讓事件訂閱者可以傳回類別的實例 SiteMapNodeThe SiteMapResolve event is raised before attempting to retrieve a SiteMapNode object, to enable event subscribers to return an instance of the SiteMapNode class. 如果沒有任何事件訂閱者,則 SiteMapProvider 類別會 FindSiteMapNode 使用目前的 HTTP 內容來呼叫方法,以取得 SiteMapNode 代表目前所要求之頁面的。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.

如果目前要求的頁面未與 a 對應 SiteMapNodenull 則會傳回。If the currently requested page does not correspond with a SiteMapNode, null is returned. 如果啟用安全性調整,而且不允許使用者存取 SiteMapNodenull 則會傳回。If security trimming is enabled and the user is not permitted to access the SiteMapNode, null is returned.

適用於

另請參閱