SiteMap.RootNode プロパティ
アセンブリ: System.Web (system.web.dll 内)

サイト ナビゲーション構造の最上位ページを表す SiteMapNode。セキュリティ トリミングが有効でノードを現在のユーザーに返せない場合は null 参照 (Visual Basic では Nothing)。


SiteMap クラスは、RootNode プロパティをプロバイダから要求して取得します。プロバイダ階層がある場合、SiteMap クラスは階層のルート プロバイダのルート ノードを取得します。既定のプロバイダのルート ノードにアクセスするには、Provider プロパティを呼び出します。これにより、既定のプロバイダとその RootNode プロパティの両方が取得されます。
SiteMap クラスの既定のプロバイダである XmlSiteMapProvider オブジェクトがサポートする RootNode は 1 つだけです。
独自の SiteMapProvider クラスを実装して、抽象プロパティ RootNode をオーバーライドする場合、SiteMapNode インスタンスの RootNode プロパティを追跡するために独自の実装を用意する必要があります。
ルート ノードはすべてのユーザーに表示されるよう設計する必要があります。セキュリティ トリミングが有効の状態でルート ノードが一部のユーザーに表示されない場合、RootNode プロパティにより InvalidOperationException 例外が発生します。

RootNode プロパティを使用して、ページ階層における現在の場所に関係なく、サイトのルート ノードを表す SiteMapNode オブジェクトを取得する方法のコード例を次に示します。
<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>
<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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からSiteMap.RootNode プロパティを検索する場合は、下記のリンクをクリックしてください。

- SiteMap.RootNode プロパティのページへのリンク