SiteMapPath イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | ItemCreated | SiteMapPath によって SiteMapNodeItem が作成され、その対応する SiteMapNode に関連付けられたときに発生します。このイベントは、OnItemCreated メソッドによって発生します。 |
![]() | ItemDataBound | SiteMapPath によって、SiteMapNodeItem がその基になる SiteMapNode データにバインドされた後に発生します。このイベントは、OnItemDataBound メソッドによって発生します。 |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |

関連項目
SiteMapPath クラスSystem.Web.UI.WebControls 名前空間
SiteMap
SiteMapProvider
SiteMapNode
SiteMapNodeItem クラス
TreeView
Menu クラス
SiteMapDataSource クラス
その他の技術情報
ASP.NET サイト ナビゲーションSiteMapPath Web サーバー コントロールの概要
ASP.NET のサイト ナビゲーションの保護
SiteMapPath クラス
アセンブリ: System.Web (system.web.dll 内)

Public Class SiteMapPath Inherits CompositeControl
public class SiteMapPath : CompositeControl
public class SiteMapPath extends CompositeControl
public class SiteMapPath extends CompositeControl

SiteMapPath コントロールは、SiteMap オブジェクトに提供されるデータを反映するサイト ナビゲーション コントロールです。このコントロールは、サイト内を簡単に移動するコンパクトな手段を提供し、現在表示されているページのサイト内の位置を示す基準点の役割を果たします。この種のコントロールは一般に階層リンクなどと呼ばれます。ハイパーリンクのページ名で階層パスが表示され、これらを使用して現在の位置から階層の上位のページに直接移動できます。SiteMapDataSource。SiteMapPath は、階層構造が深く、TreeView や Menu を使用するとページ上に必要な領域が大きすぎるというサイトに有効です。
SiteMapPath コントロールは、Web サイトのサイト マップ データと直接連携します。サイト マップに表されないページ上で使用した場合、このコントロールは表示されません。サイト マップの詳細については、「ASP.NET サイト ナビゲーションの概要」を参照してください。
SiteMapPath はノードで構成されます。パス内の各要素はノードと呼ばれ、SiteMapNodeItem オブジェクトで表されます。パスの終端位置を定め、階層ツリーの基点を表すノードは、ルート ノードと呼ばれます。現在表示されているページを表すノードは、現在のノードと呼ばれます。現在のノードとルート ノードとの間にあるノードは親ノードです。3 つの異なるノード型の説明を以下に示します。
ノード型 | |
---|---|
SiteMapPath によって表示される各ノードは、テンプレートやスタイルを適用できる HyperLink コントロールまたは Literal コントロールです。テンプレートとスタイルは、次の 2 つの優先順位規則に従ってノードに適用されます。
NodeStyle プロパティと NodeTemplate プロパティは、ノード型に関係なくすべてのノードに適用されます。これらのプロパティが両方定義されている場合は、NodeTemplate が優先されます。
CurrentNodeTemplate プロパティと CurrentNodeStyle プロパティは、現在表示されているページを表すノードに適用されます。CurrentNodeTemplate に加えて NodeTemplate が定義された場合、無視されます。NodeStyle が CurrentNodeStyle に加えて定義された場合、CurrentNodeStyle とマージされ、マージされたスタイルが作成されます。このマージされたスタイルでは、CurrentNodeStyle のすべての要素に加え、CurrentNodeStyle と競合しない NodeStyle の追加要素が使用されます。
RootNodeTemplate プロパティと RootNodeStyle プロパティは、サイト ナビゲーション階層のルートを表すノードに適用されます。RootNodeTemplate に加えて NodeTemplate が定義された場合、無視されます。NodeStyle が RootNodeStyle に加えて定義された場合、RootNodeStyle とマージされ、マージされたスタイルが作成されます。このマージされたスタイルでは、RootNodeStyle のすべての要素に加え、CurrentNodeStyle と競合しない NodeStyle の追加要素が使用されます。最後に、現在表示されているページがサイトのルート ページの場合、CurrentNodeTemplate や CurrentNodeStyle の代わりに RootNodeTemplate と RootNodeStyle が使用されます。
SiteMapPath コントロールは、サイト ナビゲーション情報のデータ ソースとして、SiteMapProvider プロパティで識別されるサイト マップ プロバイダを使用します。プロバイダが指定されない場合、SiteMap.Provider プロパティで識別される、そのサイトの既定のプロバイダを使用します。一般に、これは ASP.NET の既定のサイト マップ プロバイダである XmlSiteMapProvider のインスタンスになります。サイト内で SiteMapPath コントロールが使用されているが、サイト マップ プロバイダが構成されていない場合、コントロールは HttpException 例外をスローします。
SiteMapPath コントロールには、プログラムから利用できるイベントも用意されています。これにより、イベントが発生するたびにカスタム ルーチンが実行されるようにできます。SiteMapPath コントロールでサポートされるイベントの一覧を次の表に示します。
ItemCreated | SiteMapPath コントロールが最初に SiteMapNodeItem を作成し、SiteMapNode に関連付けたときに発生します。 |
ItemDataBound | SiteMapNodeItem が SiteMapNode に格納されているサイト マップ データにバインドされたときに発生します。 |
SiteMapPath から派生したクラスは、InitializeItem メソッドをオーバーライドして、ナビゲーション コントロールに格納されている SiteMapNodeItem コントロールをカスタマイズします。完全に制御するために SiteMapNodeItem オブジェクトを作成し、CreateControlHierarchy メソッドをオーバーライドする SiteMapPath 派生クラスに追加します。
ユーザー補助
このコントロールに既定でレンダリングされるマークアップは、Web Content Accessibility Guidelines (WCAG) 1.0 の優先度 1 ガイドラインなどのユーザー補助に関する標準に適合しない可能性があります。このコントロールのユーザー補助サポートの詳細については、「ASP.NET コントロールとユーザー補助」を参照してください。

Web フォーム ページで宣言によって SiteMapPath コントロールを使用するコード例を次に示します。この例では、テンプレートとスタイルが SiteMapPath ノードに適用される順序を規定する優先順位の規則の一部を示します。
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat="server"> </SCRIPT> <HTML> <BODY> <FORM runat="server"> <!-- The following example demonstrates some of the orders of precedence when applying styles and templates to functional nodes of a SiteMapPath. The NodeStyle and RootNodeStyle define the same attributes, but are different and conflict with each other: the RootNodeStyle supersedes NodeStyle, and is the style rendered. Notice, however, that the underline style defined by NodeStyle is still applied. Both a CurrentNodeStyle and a CurrentNodeTemplate are defined. A template supersedes a style for a node type, so CurrentNodeTemplate is displayed and CurrentNodeStyle is ignored. --> <asp:SiteMapPath ID="SiteMapPath1" runat="server" RenderCurrentNodeAsLink="true" NodeStyle-Font-Name="Franklin Gothic Medium" NodeStyle-Font-Underline="true" NodeStyle-Font-Bold="true" RootNodeStyle-Font-Name="Symbol" RootNodeStyle-Font-Bold="false" CurrentNodeStyle-Font-Name="Verdana" CurrentNodeStyle-Font-Size="10pt" CurrentNodeStyle-Font-Bold="true" CurrentNodeStyle-ForeColor="red" CurrentNodeStyle-Font-Underline="false" HoverNodeStyle-ForeColor="blue" HoverNodeStyle-Font-Underline="true"> <CURRENTNODETEMPLATE> <asp:Image id="Image1" runat="server" ImageUrl="WebForm2.jpg" AlternateText="WebForm2"/> </CURRENTNODETEMPLATE> </asp:SiteMapPath> </FORM> </BODY> </HTML>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat="server"> </SCRIPT> <HTML> <BODY> <FORM runat="server"> <!-- The following example demonstrates some of the orders of precedence when applying styles and templates to functional nodes of a SiteMapPath. The NodeStyle and RootNodeStyle define the same attributes, but are different and conflict with each other: the RootNodeStyle supersedes NodeStyle, and is the style rendered. Notice, however, that the underline style defined by NodeStyle is still applied. Both a CurrentNodeStyle and a CurrentNodeTemplate are defined. A template supersedes a style for a node type, so CurrentNodeTemplate is displayed and CurrentNodeStyle is ignored. --> <asp:SiteMapPath ID="SiteMapPath1" runat="server" RenderCurrentNodeAsLink="true" NodeStyle-Font-Name="Franklin Gothic Medium" NodeStyle-Font-Underline="true" NodeStyle-Font-Bold="true" RootNodeStyle-Font-Name="Symbol" RootNodeStyle-Font-Bold="false" CurrentNodeStyle-Font-Name="Verdana" CurrentNodeStyle-Font-Size="10pt" CurrentNodeStyle-Font-Bold="true" CurrentNodeStyle-ForeColor="red" CurrentNodeStyle-Font-Underline="false" HoverNodeStyle-ForeColor="blue" HoverNodeStyle-Font-Underline="true"> <CURRENTNODETEMPLATE> <asp:Image id="Image1" runat="server" ImageUrl="WebForm2.jpg" AlternateText="WebForm2"/> </CURRENTNODETEMPLATE> </asp:SiteMapPath> </FORM> </BODY> </HTML>
<%@ Page Language="VJ#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat="server"> </SCRIPT> <HTML> <BODY> <FORM runat="server"> <!-- The following example demonstrates some of the orders of precedence when applying styles and templates to functional nodes of a SiteMapPath. The NodeStyle and RootNodeStyle define the same attributes, but are different and conflict with each other: the RootNodeStyle supercedes NodeStyle, and is the style rendered. Notice, however, that the underline style defined by NodeStyle is still applied. Both a CurrentNodeStyle and a CurrentNodeTemplate are defined. A template supercedes a style for a node type, so CurrentNodeTemplate is displayed and CurrentNodeStyle is ignored. --> <asp:SiteMapPath ID="SiteMapPath1" runat="server" RenderCurrentNodeAsLink="true" NodeStyle-Font-Name="Franklin Gothic Medium" NodeStyle-Font-Underline="true" NodeStyle-Font-Bold="true" RootNodeStyle-Font-Name="Symbol" RootNodeStyle-Font-Bold="false" CurrentNodeStyle-Font-Name="Verdana" CurrentNodeStyle-Font-Size="10pt" CurrentNodeStyle-Font-Bold="true" CurrentNodeStyle-ForeColor="red" CurrentNodeStyle-Font-Underline="false" HoverNodeStyle-ForeColor="blue" HoverNodeStyle-Font-Underline="true"> <CURRENTNODETEMPLATE> <asp:Image id="Image1" runat="server" ImageUrl="WebForm2.jpg" AlternateText="WebForm2"/> </CURRENTNODETEMPLATE> </asp:SiteMapPath> </FORM> </BODY> </HTML>
上記の例では、既定のサイト マップ プロバイダと以下の構造を持つ Web.sitemap ファイルを使用します。
<siteMap> <siteMapNode title="WebForm1" description="WebForm1" url="WebForm1.aspx" > <siteMapNode title="WebForm2" description="WebForm2" url="WebForm2.aspx"/> </siteMapNode> </siteMap>
SiteMapPath コントロールを拡張し、InitializeItem メソッドをオーバーライドして新しい機能を追加するコード例を次に示します。DropDownSiteMapPath コントロールは DropDownList を現在のノードの後に追加し、現在のページの子ノードになっているページへ簡単に移動できるようにします。この例では、SiteMapNodeItemType の確認や項目を作成した後の OnItemCreated メソッドの呼び出しを含む、SiteMapNodeItem オブジェクトの使用方法を示します。
Imports System Imports System.Collections Imports System.ComponentModel Imports System.Security.Permissions Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Namespace Samples.AspNet ' The DropDownNavigationPath is a class that extends the SiteMapPath ' control and renders a DropDownList after the CurrentNode. The ' DropDownList displays a list of pages found further down the site map ' hierarchy from the current one. Selecting an item in the DropDownList ' redirects to that page. ' ' For simplicity, the DropDownNavigationPath assumes the ' RootToCurrent PathDirection, and does not apply styles ' or templates the current node. ' <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _ Public Class DropDownNavigationPath Inherits SiteMapPath ' Override the InitializeItem method to add a PathSeparator ' and DropDownList to the current node. Protected Overrides Sub InitializeItem(item As SiteMapNodeItem) ' The only node that must be handled is the CurrentNode. If item.ItemType = SiteMapNodeItemType.Current Then Dim hLink As New HyperLink() ' No Theming for the HyperLink. hLink.EnableTheming = False ' Enable the link of the SiteMapPath is enabled. hLink.Enabled = Me.Enabled ' Set the properties of the HyperLink to ' match those of the corresponding SiteMapNode. hLink.NavigateUrl = item.SiteMapNode.Url hLink.Text = item.SiteMapNode.Title If ShowToolTips Then hLink.ToolTip = item.SiteMapNode.Description End If ' Apply styles or templates to the HyperLink here. ' ... ' ... ' Add the item to the Controls collection. item.Controls.Add(hLink) AddDropDownListAfterCurrentNode(item) Else MyBase.InitializeItem(item) End If End Sub 'InitializeItem Private Sub AddDropDownListAfterCurrentNode(item As SiteMapNodeItem) Dim childNodes As SiteMapNodeCollection = item.SiteMapNode.ChildNodes ' Only do this work if there are child nodes. If Not (childNodes Is Nothing) Then ' Add another PathSeparator after the CurrentNode. Dim finalSeparator As New SiteMapNodeItem(item.ItemIndex, SiteMapNodeItemType.PathSeparator) Dim eventArgs As New SiteMapNodeItemEventArgs(finalSeparator) InitializeItem(finalSeparator) ' Call OnItemCreated every time a SiteMapNodeItem is ' created and initialized. OnItemCreated(eventArgs) ' The pathSeparator does not bind to any SiteMapNode, so ' do not call DataBind on the SiteMapNodeItem. item.Controls.Add(finalSeparator) ' Create a DropDownList and populate it with the children of the ' CurrentNode. There are no styles or templates that are applied ' to the DropDownList control. If OnSelectedIndexChanged is raised, ' the event handler redirects to the page selected. ' The CurrentNode has child nodes. Dim ddList As New DropDownList() ddList.AutoPostBack = True AddHandler ddList.SelectedIndexChanged, AddressOf Me.DropDownNavPathEventHandler ' Add a ListItem to the DropDownList for every node in the ' SiteMapNodes collection. Dim node As SiteMapNode For Each node In childNodes ddList.Items.Add(New ListItem(node.Title, node.Url)) Next node item.Controls.Add(ddList) End If End Sub 'AddDropDownListAfterCurrentNode ' The sender is the DropDownList. Private Sub DropDownNavPathEventHandler(sender As Object, e As EventArgs) Dim ddL As DropDownList = CType(sender, DropDownList) ' Redirect to the page the user chose. If Not (Context Is Nothing) Then Context.Response.Redirect(ddL.SelectedValue) End If End Sub 'DropDownNavPathEventHandler End Class 'DropDownNavigationPath End Namespace
using System; using System.Collections; using System.ComponentModel; using System.Security.Permissions; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; // The DropDownNavigationPath is a class that extends the SiteMapPath // control and renders a DropDownList after the CurrentNode. The // DropDownList displays a list of pages found further down the site map // hierarchy from the current one. Selecting an item in the DropDownList // redirects to that page. // // For simplicity, the DropDownNavigationPath assumes the // RootToCurrent PathDirection, and does not apply styles // or templates the current node. // [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)] public class DropDownNavigationPath : SiteMapPath { // Override the InitializeItem method to add a PathSeparator // and DropDownList to the current node. protected override void InitializeItem(SiteMapNodeItem item) { // The only node that must be handled is the CurrentNode. if (item.ItemType == SiteMapNodeItemType.Current) { HyperLink hLink = new HyperLink(); // No Theming for the HyperLink. hLink.EnableTheming = false; // Enable the link of the SiteMapPath is enabled. hLink.Enabled = this.Enabled; // Set the properties of the HyperLink to // match those of the corresponding SiteMapNode. hLink.NavigateUrl = item.SiteMapNode.Url; hLink.Text = item.SiteMapNode.Title; if (ShowToolTips) { hLink.ToolTip = item.SiteMapNode.Description; } // Apply styles or templates to the HyperLink here. // ... // ... // Add the item to the Controls collection. item.Controls.Add(hLink); AddDropDownListAfterCurrentNode(item); } else { base.InitializeItem(item); } } private void AddDropDownListAfterCurrentNode(SiteMapNodeItem item) { SiteMapNodeCollection childNodes = item.SiteMapNode.ChildNodes; // Only do this work if there are child nodes. if (childNodes != null) { // Add another PathSeparator after the CurrentNode. SiteMapNodeItem finalSeparator = new SiteMapNodeItem(item.ItemIndex, SiteMapNodeItemType.PathSeparator); SiteMapNodeItemEventArgs eventArgs = new SiteMapNodeItemEventArgs(finalSeparator); InitializeItem(finalSeparator); // Call OnItemCreated every time a SiteMapNodeItem is // created and initialized. OnItemCreated(eventArgs); // The pathSeparator does not bind to any SiteMapNode, so // do not call DataBind on the SiteMapNodeItem. item.Controls.Add(finalSeparator); // Create a DropDownList and populate it with the children of the // CurrentNode. There are no styles or templates that are applied // to the DropDownList control. If OnSelectedIndexChanged is raised, // the event handler redirects to the page selected. // The CurrentNode has child nodes. DropDownList ddList = new DropDownList(); ddList.AutoPostBack = true; ddList.SelectedIndexChanged += new EventHandler(this.DropDownNavPathEventHandler); // Add a ListItem to the DropDownList for every node in the // SiteMapNodes collection. foreach (SiteMapNode node in childNodes) { ddList.Items.Add(new ListItem(node.Title, node.Url)); } item.Controls.Add(ddList); } } // The sender is the DropDownList. private void DropDownNavPathEventHandler(object sender,EventArgs e) { DropDownList ddL = sender as DropDownList; // Redirect to the page the user chose. if (Context != null) Context.Response.Redirect(ddL.SelectedValue); } }
import System.*; import System.Collections.*; import System.ComponentModel.*; import System.Web.*; import System.Web.UI.*; import System.Web.UI.WebControls.*; // The DropDownNavigationPath is a class that extends the SiteMapPath // control and renders a DropDownList after the CurrentNode. The // DropDownList displays a list of pages found further down the site map // hierarchy from the current one. Selecting an item in the DropDownList // redirects to that page. // // For simplicity, the DropDownNavigationPath assumes the // RootToCurrent PathDirection, and does not apply styles // or templates the current node. // public class DropDownNavigationPath extends SiteMapPath { // Override the InitializeItem method to add a PathSeparator // and DropDownList to the current node. protected void InitializeItem(SiteMapNodeItem item) { // The only node that must be handled is the CurrentNode. if (item.get_ItemType().Equals(SiteMapNodeItemType.Current)) { HyperLink hLink = new HyperLink(); // No Theming for the HyperLink. hLink.set_EnableTheming(false); // Enable the link of the SiteMapPath is enabled. hLink.set_Enabled(this.get_Enabled()); // Set the properties of the HyperLink to // match those of the corresponding SiteMapNode. hLink.set_NavigateUrl(item.get_SiteMapNode().get_Url()); hLink.set_Text(item.get_SiteMapNode().get_Title()); if (get_ShowToolTips()) { hLink.set_ToolTip(item.get_SiteMapNode().get_Description()); } // Apply styles or templates to the HyperLink here. // ... // ... // Add the item to the Controls collection. item.get_Controls().Add(hLink); AddDropDownListAfterCurrentNode(item); } else { super.InitializeItem(item); } } //InitializeItem private void AddDropDownListAfterCurrentNode(SiteMapNodeItem item) { SiteMapNodeCollection childNodes = item.get_SiteMapNode(). get_ChildNodes(); // Only do this work if there are child nodes. if (childNodes != null) { // Add another PathSeparator after the CurrentNode. SiteMapNodeItem finalSeparator = new SiteMapNodeItem(item. get_ItemIndex(), SiteMapNodeItemType.PathSeparator); SiteMapNodeItemEventArgs eventArgs = new SiteMapNodeItemEventArgs( finalSeparator); InitializeItem(finalSeparator); // Call OnItemCreated every time a SiteMapNodeItem is // created and initialized. OnItemCreated(eventArgs); // The pathSeparator does not bind to any SiteMapNode, so // do not call DataBind on the SiteMapNodeItem. item.get_Controls().Add(finalSeparator); // Create a DropDownList and populate it with the children of the // CurrentNode. There are no styles or templates that are applied // to the DropDownList control. If OnSelectedIndexChanged is raised, // the event handler redirects to the page selected. // The CurrentNode has child nodes. DropDownList ddList = new DropDownList(); ddList.set_AutoPostBack(true); ddList.add_SelectedIndexChanged(new EventHandler(this. DropDownNavPathEventHandler)); // Add a ListItem to the DropDownList for every node in the // SiteMapNodes collection. for (int iCtr = 0; iCtr < childNodes.get_Count(); iCtr++) { SiteMapNode node = (SiteMapNode)childNodes.get_Item(iCtr); ddList.get_Items().Add(new ListItem(node.get_Title(), node. get_Url())); } item.get_Controls().Add(ddList); } } //AddDropDownListAfterCurrentNode // The sender is the DropDownList. public void DropDownNavPathEventHandler(Object sender, EventArgs e) { DropDownList ddL = (DropDownList)sender; // Redirect to the page the user chose. if (get_Context() != null) { get_Context().get_Response().Redirect(ddL.get_SelectedValue()); } } //DropDownNavPathEventHandler } //DropDownNavigationPath


System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.CompositeControl
System.Web.UI.WebControls.SiteMapPath


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SiteMapPath コンストラクタ
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタを使用して、SiteMapPath クラスの新しいインスタンスを作成し、初期化します。SiteMapPath コントロールをページに動的に追加するには、新しい SiteMapPath オブジェクトを作成してそのプロパティを設定し、PlaceHolder など、コンテナ コントロールの Control.Controls コレクションに追加します。

SiteMapPath コンストラクタを使用して、SiteMapPath コントロールをページに追加する方法を次のコード例に示します。このコード例を実行するには、イメージをルート ディレクトリに追加し、コード例のイメージ名を "myimage.jpg" からそのイメージ ファイルの名前に変更する必要があります。
<%@ Page language="VB"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat="server"> Private Sub Page_Load(sender As Object, e As EventArgs) ' Create the SiteMapPath control. Dim navpath As New SiteMapPath() ' Make the root node look unique. ' The Image that you can use in your Web page is an ' instance of the WebControls.Image class, not the ' Drawing.Image class. Dim rootNodeImage As New System.Web.UI.WebControls.Image() rootNodeImage.ImageUrl = "myimage.jpg" Dim rootNodeImageTemplate As New ImageTemplate() rootNodeImageTemplate.MyImage = rootNodeImage navpath.RootNodeTemplate = rootNodeImageTemplate ' Make the current node look unique. Dim currentNodeStyle As New Style() navpath.CurrentNodeStyle.ForeColor = System.Drawing.Color.AliceBlue navpath.CurrentNodeStyle.BackColor = System.Drawing.Color.Bisque ' Set the path separator to be something other ' than the default. navpath.PathSeparator = "::" PlaceHolder1.Controls.Add(navpath) End Sub ' Page_Load ' A simple Template class to wrap an image. Public Class ImageTemplate Implements ITemplate Private anImage As System.Web.UI.WebControls.Image Public Property MyImage As System.Web.UI.WebControls.Image Get return anImage End Get Set anImage = value End Set End Property ' MyImage Public Overridable Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn container.Controls.Add(MyImage) End Sub ' InstantiateIn End Class ' ImageTemplate </SCRIPT> <HTML> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder> <h1>About Our Company</h1> <p>Our company was founded in 1886.</p> <p>We use only the finest ingredients, organically grown fruits, and natural spices in our homemade pies. We use no artificial preservatives or coloring agents. We would not have it any other way!</p> </form> </body> </HTML>
<%@ Page language="c#"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat="server"> private void Page_Load(object sender, System.EventArgs e) { // Create the SiteMapPath control. SiteMapPath navpath = new SiteMapPath(); // Make the root node look unique. // The Image that you can use in your Web page is an // instance of the WebControls.Image class, not the // Drawing.Image class. System.Web.UI.WebControls.Image rootNodeImage = new System.Web.UI.WebControls.Image(); rootNodeImage.ImageUrl = "myimage.jpg"; ImageTemplate rootNodeImageTemplate = new ImageTemplate(); rootNodeImageTemplate.MyImage = rootNodeImage; navpath.RootNodeTemplate = rootNodeImageTemplate; // Make the current node look unique. Style currentNodeStyle = new Style(); navpath.CurrentNodeStyle.ForeColor = System.Drawing.Color.AliceBlue; navpath.CurrentNodeStyle.BackColor = System.Drawing.Color.Bisque; // Set the path separator to be something other // than the default. navpath.PathSeparator = "::"; PlaceHolder1.Controls.Add(navpath); } // A simple Template class to wrap an image. public class ImageTemplate : ITemplate { private System.Web.UI.WebControls.Image myImage; public System.Web.UI.WebControls.Image MyImage { get { return myImage; } set { myImage = value; } } public void InstantiateIn(Control container) { container.Controls.Add(MyImage); } } </SCRIPT> <HTML> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder> <h1>About Our Company</h1> <p>Our company was founded in 1886.</p> <p>We use only the finest ingredients, organically grown fruits, and natural spices in our homemade pies. We use no artificial preservatives or coloring agents. We would not have it any other way!</p> </form> </body> </HTML>
<%@ Page language="VJ#"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <SCRIPT runat="server"> private void Page_Load(Object sender, System.EventArgs e) { // Create the SiteMapPath control. SiteMapPath navpath = new SiteMapPath(); // Make the root node look unique. // The Image that you can use in your Web page is an // instance of the WebControls.Image class, not the // Drawing.Image class. System.Web.UI.WebControls.Image rootNodeImage = new System.Web.UI.WebControls.Image(); rootNodeImage.set_ImageUrl("myimage.jpg"); ImageTemplate rootNodeImageTemplate = new ImageTemplate(); rootNodeImageTemplate.set_myImage(rootNodeImage); navpath.set_RootNodeTemplate(rootNodeImageTemplate); // Make the current node look unique. Style currentNodeStyle = new Style(); navpath.get_CurrentNodeStyle().set_ForeColor(System.Drawing.Color.get_AliceBlue()); navpath.get_CurrentNodeStyle().set_BackColor(System.Drawing.Color.get_Bisque()); // Set the path separator to be something other // than the default. navpath.set_PathSeparator("---->"); PlaceHolder1.get_Controls().Add(navpath); } // A simple Template class to wrap an image. public class ImageTemplate implements ITemplate { private System.Web.UI.WebControls.Image myImage; public System.Web.UI.WebControls.Image get_myImage() { return myImage; } public void set_myImage(System.Web.UI.WebControls.Image value) { myImage = value; } public void InstantiateIn(Control container) { container.get_Controls().Add(myImage); } } </SCRIPT> <HTML> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder> <h1>About Our Company</h1> <p>Grandma Fanny founded our company in 1886.</p> <p>We use only the finest ingredients, organically grown fruits, and natural spices in our homemade pies. We use no artificial preservatives or coloring agents. Grandma Fanny would not have it any other way!</p> </form> </body> </HTML>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SiteMapPath クラス
SiteMapPath メンバ
System.Web.UI.WebControls 名前空間
その他の技術情報
ASP.NET サイト ナビゲーション
SiteMapPath Web サーバー コントロールの概要
SiteMapPath プロパティ



関連項目
SiteMapPath クラスSystem.Web.UI.WebControls 名前空間
SiteMap
SiteMapProvider
SiteMapNode
SiteMapNodeItem クラス
TreeView
Menu クラス
SiteMapDataSource クラス
その他の技術情報
ASP.NET サイト ナビゲーションSiteMapPath Web サーバー コントロールの概要
ASP.NET のサイト ナビゲーションの保護
SiteMapPath メソッド



関連項目
SiteMapPath クラスSystem.Web.UI.WebControls 名前空間
SiteMap
SiteMapProvider
SiteMapNode
SiteMapNodeItem クラス
TreeView
Menu クラス
SiteMapDataSource クラス
その他の技術情報
ASP.NET サイト ナビゲーションSiteMapPath Web サーバー コントロールの概要
ASP.NET のサイト ナビゲーションの保護
SiteMapPath メンバ
最小限のページ領域で、より簡単に Web サイト内を移動できるようにする、一連のテキストやイメージのハイパーリンクを表示します。
SiteMapPath データ型で公開されるメンバを以下の表に示します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | ItemCreated | SiteMapPath によって SiteMapNodeItem が作成され、その対応する SiteMapNode に関連付けられたときに発生します。このイベントは、OnItemCreated メソッドによって発生します。 |
![]() | ItemDataBound | SiteMapPath によって、SiteMapNodeItem がその基になる SiteMapNode データにバインドされた後に発生します。このイベントは、OnItemDataBound メソッドによって発生します。 |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |

関連項目
SiteMapPath クラスSystem.Web.UI.WebControls 名前空間
SiteMap
SiteMapProvider
SiteMapNode
SiteMapNodeItem クラス
TreeView
Menu クラス
SiteMapDataSource クラス
その他の技術情報
ASP.NET サイト ナビゲーションSiteMapPath Web サーバー コントロールの概要
ASP.NET のサイト ナビゲーションの保護
- SiteMapPathのページへのリンク