SiteMapPath.InitializeItem メソッド
アセンブリ: System.Web (system.web.dll 内)


InitializeItem メソッドは、SiteMapNodeItemType を確認して、その項目が表すノードの機能上の型を判別し、その型のノードに定義されているテンプレートやスタイルを適用します。
SiteMapNodeItem の項目の型が Root の場合、子コントロールである HyperLink が作成され、RootNodeTemplate と RootNodeStyle が適用されます。RootNodeTemplate が設定されている場合、ITemplate がノードに適用されます。代わりに RootNodeStyle が設定されている場合、定義済みの NodeStyle でマージされて適用されます。最後に、テンプレートやスタイルが定義されていない場合、基本の HyperLink コントロールが作成され、ノードの値で初期化されます。
SiteMapNodeItem の項目の型が Current の場合、RenderCurrentNodeAsLink の戻り値に基づいて、子コントロールである Literal または HyperLink が作成されます。その後、CurrentNodeTemplate または CurrentNodeStyle が適用されます。CurrentNodeTemplate が設定されている場合、ITemplate がノードに適用されます。代わりに CurrentNodeStyle が設定されている場合、定義済みの NodeStyle でマージされて適用されます。
SiteMapNodeItem の項目の型が Parent の場合、子コントロールである HyperLink が作成され、NodeTemplate と NodeStyle が適用されます。NodeTemplate が設定されている場合、ITemplate がノードに適用されます。代わりに NodeStyle が設定されている場合、それが適用されます。
最後に、SiteMapNodeItem の項目の型が PathSeparator の場合、子コントロールである Literal が作成され、Parent のノード型に定義される同一の一般規則に従って PathSeparatorTemplate と PathSeparatorStyle が適用されます。
個々の SiteMapNodeItem オブジェクトを操作するには、InitializeItem メソッドをオーバーライドします。SiteMapNodeItem オブジェクトを作成し、SiteMapPath コントロールに追加する方法について、より広範な制御が必要な場合は、CreateControlHierarchy メソッドをオーバーライドします。

InitializeItem メソッドをオーバーライドして、SiteMapPath から派生したコントロールに機能を追加する方法を次のコード例に示します。このコード例は、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
// 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); } }
// 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

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 名前空間
CreateControlHierarchy
その他の技術情報
ASP.NET サイト ナビゲーション
SiteMapPath Web サーバー コントロールの概要
Weblioに収録されているすべての辞書からSiteMapPath.InitializeItem メソッドを検索する場合は、下記のリンクをクリックしてください。

- SiteMapPath.InitializeItem メソッドのページへのリンク