SiteMap.CurrentNode プロパティ

定義

現在要求されているページを表す SiteMapNode コントロールを取得します。

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

プロパティ値

現在要求されているページを表す SiteMapNode インスタンス。サイト マップ情報に表示するノードがない場合は null

例外

このサイト マップ機能は無効になっています。

構成に指定されている既定のプロバイダーが存在しません。

この機能は、信頼性が低以上の場合にのみサポートされます。

次のコード例では、 プロパティを使用して、現在の CurrentNode ページを SiteMapNode 表す オブジェクトを取得する方法を示します。

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
    // Examine the CurrentNode, and navigate the SiteMap relative to it.
    Response.Write(SiteMap.CurrentNode.Title + "<br />");
    Response.Write("<font COLOR='red'>" + SiteMap.CurrentNode.Url + "</font><br />");

    // What nodes are children of the CurrentNode?
    if (SiteMap.CurrentNode.HasChildNodes) {
        IEnumerator childNodesEnumerator = SiteMap.CurrentNode.ChildNodes.GetEnumerator();
        while (childNodesEnumerator.MoveNext()) {
            // Prints the Title of each node.
            Response.Write(childNodesEnumerator.Current.ToString() + "<br />");
        }
    }
    Response.Write("<hr />");

    // Examine the RootNode, and navigate the SiteMap relative to it.
    Response.Write(SiteMap.RootNode.Title + "<br />");
    Response.Write(SiteMap.RootNode.Url + "<br />");

    // What nodes are children of the RootNode?
    if (SiteMap.RootNode.HasChildNodes) {
        IEnumerator rootNodesChildrenEnumerator = SiteMap.RootNode.ChildNodes.GetEnumerator();
        while (rootNodesChildrenEnumerator.MoveNext()) {
            // Prints the Title of each node.
            Response.Write(rootNodesChildrenEnumerator.Current.ToString() + "<br />");
        }
    }
}
</script>
<script runat="server">

Private Sub Page_Load(sender As Object, e As EventArgs)

    ' Examine the CurrentNode, and navigate the SiteMap relative to it.
    Response.Write(SiteMap.CurrentNode.Title & "<br />")
    Response.Write("<font COLOR='red'>" & SiteMap.CurrentNode.Url & "</font><br />")

    ' What nodes are children of the CurrentNode?
    If (SiteMap.CurrentNode.HasChildNodes) Then
        Dim ChildNodesEnumerator As IEnumerator = SiteMap.CurrentNode.ChildNodes.GetEnumerator()
        While (ChildNodesEnumerator.MoveNext())
            ' Prints the Title of each node.
            Response.Write(ChildNodesEnumerator.Current.ToString() & "<br />")
        End While
    End If
    Response.Write("<hr />")

    ' Examine the RootNode, and navigate the SiteMap relative to it.
    Response.Write(SiteMap.RootNode.Title & "<br />")
    Response.Write(SiteMap.RootNode.Url & "<br />")

    ' What nodes are children of the RootNode?
    If (SiteMap.RootNode.HasChildNodes) Then
        Dim RootNodesChildrenEnumerator As IEnumerator = SiteMap.RootNode.ChildNodes.GetEnumerator()
        While (RootNodesChildrenEnumerator.MoveNext())
            ' Prints the Title of each node.
            Response.Write(RootNodesChildrenEnumerator.Current.ToString() & "<br />")
        End While
    End If

End Sub ' Page_Load
</script>

注釈

クラスは SiteMap 、プロバイダーに CurrentNode 要求して プロパティを取得します。

サイト マップ情報にページの代表的なノードが存在しない場合、またはセキュリティ トリミングが有効で、現在のユーザーに対してノードを返すことができない場合は、 null が返されます。

イベントは SiteMapResolve 、1 つ以上のサブスクリプションが存在する場合、既定のサイト マップ プロバイダーによって発生します。

独自 SiteMapProvider の オブジェクトを実装する場合は、 を検索して取得するための独自のメカニズムを CurrentNode作成できます。 ただし、 クラスを StaticSiteMapProvider 拡張し、URL ベースのスキームを使用してページを識別する場合は、 メソッドを FindSiteMapNode オーバーライドできます。

適用対象

こちらもご覧ください