SiteMapNodeItem.ItemType 屬性

定義

擷取 SiteMapNodeItem 的功能型別。

public:
 virtual property System::Web::UI::WebControls::SiteMapNodeItemType ItemType { System::Web::UI::WebControls::SiteMapNodeItemType get(); };
public virtual System.Web.UI.WebControls.SiteMapNodeItemType ItemType { get; }
member this.ItemType : System.Web.UI.WebControls.SiteMapNodeItemType
Public Overridable ReadOnly Property ItemType As SiteMapNodeItemType

屬性值

SiteMapNodeItemType 列舉型別的成員,表示節點項目在巡覽路徑階層架構中的功能角色。

範例

下列程式碼範例示範如何使用 屬性來檢查 的類型 SiteMapNodeItemItemType 。 在此範例中,方法處理的唯一節點類型 InitializeItem 是 型別 CurrentNode 。 此程式碼範例是針對 類別提供的較大範例的 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);
    }
}
' 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

備註

SiteMapNodeItem 具有 PathSeparator 型別的物件不會系結至對應的 SiteMapNode

適用於

另請參閱