SiteMapPath.InitializeItem メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SiteMapPath.InitializeItem メソッドの意味・解説 

SiteMapPath.InitializeItem メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

SiteMapNode を表す Web サーバー コントロールの SiteMapNodeItem に、ノードの機能およびノードに指定したテンプレートとスタイルに基づいて一連の子コントロールを読み込みます。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Protected Overridable Sub
 InitializeItem ( _
    item As SiteMapNodeItem _
)
Dim item As SiteMapNodeItem

Me.InitializeItem(item)
protected virtual void InitializeItem (
    SiteMapNodeItem item
)
protected:
virtual void InitializeItem (
    SiteMapNodeItem^ item
)
protected void InitializeItem (
    SiteMapNodeItem item
)
protected function InitializeItem (
    item : SiteMapNodeItem
)

パラメータ

item

初期化する SiteMapNodeItem。

解説解説

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

SiteMapPath.InitializeItem メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SiteMapPath.InitializeItem メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS