SiteMapProvider.CurrentNode 屬性

定義

取得代表目前所要求頁面的 SiteMapNode 物件。

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 或無法為目前使用者傳回,則為 null

範例

下列程式碼範例示範如何在實作抽象 SiteMapProvider 類的類別中實 CurrentNode 作 屬性。

此程式碼範例是針對 類別提供的較大範例的 SiteMapProvider 一部分。

// 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 物件之前,會引發 事件,讓事件訂閱者傳回 類別的 SiteMapNode 實例。 如果沒有事件訂閱者,類別會 SiteMapProvider 使用目前的 HTTP 內容呼叫 FindSiteMapNode 方法,以擷取 SiteMapNode 代表目前要求之頁面的 。

如果目前要求的頁面未對應至 SiteMapNodenull 則會傳回 。 如果啟用安全性調整,且不允許使用者存取 SiteMapNodenull 則會傳回 。

適用於

另請參閱