SubMenuStyle 類別

定義

表示 Menu 控制項中的子功能表樣式。

public ref class SubMenuStyle : System::Web::UI::WebControls::Style, System::ComponentModel::ICustomTypeDescriptor
public class SubMenuStyle : System.Web.UI.WebControls.Style, System.ComponentModel.ICustomTypeDescriptor
type SubMenuStyle = class
    inherit Style
    interface ICustomTypeDescriptor
Public Class SubMenuStyle
Inherits Style
Implements ICustomTypeDescriptor
繼承
實作

範例

下列範例示範如何在動態功能表內指定子功能表的自訂樣式。


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu DynamicMenuStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu DynamicMenuStyle Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <dynamicmenustyle backcolor="LightSkyBlue"
          forecolor="Black"
          borderstyle="Solid"
          borderwidth="1"
          bordercolor="Black" />
      
        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Home"
            tooltip="Home">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx" 
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Movies"
              tooltip="Movies">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>Menu DynamicMenuStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu DynamicMenuStyle Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <dynamicmenustyle backcolor="LightSkyBlue"
          forecolor="Black"
          borderstyle="Solid"
          borderwidth="1"
          bordercolor="Black" />
      
        <items>
          <asp:menuitem navigateurl="Home.aspx" 
            text="Home"
            tooltip="Home">
            <asp:menuitem navigateurl="Music.aspx"
              text="Music"
              tooltip="Music">
              <asp:menuitem navigateurl="Classical.aspx" 
                text="Classical"
                tooltip="Classical"/>
              <asp:menuitem navigateurl="Rock.aspx"
                text="Rock"
                tooltip="Rock"/>
              <asp:menuitem navigateurl="Jazz.aspx"
                text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem navigateurl="Movies.aspx"
              text="Movies"
              tooltip="Movies">
              <asp:menuitem navigateurl="Action.aspx"
                text="Action"
                tooltip="Action"/>
              <asp:menuitem navigateurl="Drama.aspx"
                text="Drama"
                tooltip="Drama"/>
              <asp:menuitem navigateurl="Musical.aspx"
                text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

    </form>
  </body>
</html>

備註

SubMenuStyle使用 類別來表示 控制項中 Menu 子功能表的樣式。 子功能表可以在靜態功能表或動態功能表中顯示。 靜態功能表一律會顯示在 Menu 控制項上,而動態功能表只有在使用者將滑鼠指標放在包含動態子功能表的父功能表項目上時才會顯示。 您可以使用下表中的屬性,指定不同的樣式特性 (,例如靜態功能表內的子功能表字型大小和色彩) 。

子功能表專案樣式屬性 描述
DynamicMenuStyle 動態功能表內子功能表的樣式設定。
StaticMenuStyle 靜態功能表內子功能表的樣式設定。

類別 SubMenuStyle 會繼承 Style 類別的大部分成員。 它會提供屬性來控制功能表項目文字周圍的空間量,藉以擴充 Style 類別。 HorizontalPadding使用 屬性來控制功能表項目文字左邊和右邊的空間量。 同樣地, VerticalPadding 屬性會控制功能表項目文字上方和下方的空間量。

如需繼承樣式設定的詳細資訊,請參閱 Style

注意

z-index設定子功能表樣式的 屬性,以設定 CssClass 與子功能表相關聯的 HTML 物件。 屬性 z-index 會定義轉譯 HTML 物件的堆疊順序。 根據預設,動態功能表項目會出現在任何具有預設 z 索引 (0) 的 HTML 物件上方。

建構函式

SubMenuStyle()

初始化 SubMenuStyle 類別的新執行個體。

SubMenuStyle(StateBag)

使用指定的檢視狀態資訊,初始化 SubMenuStyle 類別的新執行個體。

屬性

BackColor

取得或設定 Web 伺服器控制項的背景色彩。

(繼承來源 Style)
BorderColor

取得或設定 Web 伺服器控制項的框線色彩。

(繼承來源 Style)
BorderStyle

取得或設定 Web 伺服器控制項的框線樣式。

(繼承來源 Style)
BorderWidth

取得或設定 Web 伺服器控制項的框線寬度。

(繼承來源 Style)
CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
Container

取得包含 IContainerComponent

(繼承來源 Component)
CssClass

取得或設定用戶端上 Web 伺服器控制項所呈現的階層式樣式表 (CSS)。

(繼承來源 Style)
DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
Font

取得與 Web 伺服器控制項關聯的字型屬性。

(繼承來源 Style)
ForeColor

取得或設定 Web 伺服器控制項的前景色彩 (通常是文字的色彩)。

(繼承來源 Style)
Height

取得或設定 Web 伺服器控制項的高度。

(繼承來源 Style)
HorizontalPadding

取得或設定子功能表的左右間距。

IsEmpty

保護的 (Protected) 屬性。 取得值,指出狀態包中是否已定義任何樣式項目。

(繼承來源 Style)
IsTrackingViewState

傳回值,指出是否任何的樣式項目都已經在狀態包中定義。

(繼承來源 Style)
RegisteredCssClass

取得使用控制項註冊的階層式樣式表 (CSS) 類別。

(繼承來源 Style)
Site

取得或設定 ComponentISite

(繼承來源 Component)
VerticalPadding

取得或設定子功能表的上下間距。

ViewState

取得保存樣式項目的狀態包。

(繼承來源 Style)
Width

取得或設定 Web 伺服器控制項的寬度。

(繼承來源 Style)

方法

AddAttributesToRender(HtmlTextWriter)

將需要呈現的 HTML 屬性和樣式加入至指定的 HtmlTextWriter 中。 這個方法主要由控制項開發人員使用。

(繼承來源 Style)
AddAttributesToRender(HtmlTextWriter, WebControl)

將需要呈現的 HTML 屬性和樣式加入至指定的 HtmlTextWriter 和 Web 伺服器控制項中。 這個方法主要由控制項開發人員使用。

(繼承來源 Style)
CopyFrom(Style)

將指定 Style 物件的樣式屬性複製到 SubMenuStyle 類別的目前執行個體中。

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Component)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FillStyleAttributes(CssStyleCollection, IUrlResolutionService)

SubMenuStyle 物件的樣式屬性加入指定的 CssStyleCollection 物件中。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已過時。

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetStyleAttributes(IUrlResolutionService)

擷取指定 CssStyleCollection 實作物件的 IUrlResolutionService 物件。

(繼承來源 Style)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已過時。

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
LoadViewState(Object)

載入先前儲存的狀態。

(繼承來源 Style)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
MergeWith(Style)

將指定 Style 物件的樣式屬性與 SubMenuStyle 類別目前執行個體的樣式屬性結合。

Reset()

SubMenuStyle 類別的目前執行個體返回其原始狀態。

SaveViewState()

保護的 (Protected) 方法。 儲存叫用 TrackViewState() 方法之後,任何已變更的狀態。

(繼承來源 Style)
SetBit(Int32)

保護的內部方法。 設定內部位元遮罩欄位,表示儲存在狀態包中的樣式屬性。

(繼承來源 Style)
SetDirty()

標記 Style,以便將其狀態記錄在檢視狀態中。

(繼承來源 Style)
ToString()

傳回代表目前物件的字串。

(繼承來源 Style)
TrackViewState()

保護的 (Protected) 方法。 在控制項上標記追蹤狀態變更的開頭。 任何在追蹤開始後的變更都會被追蹤,並儲存成控制項檢視狀態的一部分。

(繼承來源 Style)

事件

Disposed

Dispose() 方法的呼叫處置元件時,就會發生。

(繼承來源 Component)

明確介面實作

ICustomTypeDescriptor.GetAttributes()

如需這個成員的說明,請參閱 GetAttributes()

ICustomTypeDescriptor.GetClassName()

如需這個成員的說明,請參閱 GetClassName()

ICustomTypeDescriptor.GetComponentName()

如需這個成員的說明,請參閱 GetComponentName()

ICustomTypeDescriptor.GetConverter()

如需這個成員的說明,請參閱 GetConverter()

ICustomTypeDescriptor.GetDefaultEvent()

如需這個成員的說明,請參閱 GetDefaultEvent()

ICustomTypeDescriptor.GetDefaultProperty()

如需這個成員的說明,請參閱 GetDefaultProperty()

ICustomTypeDescriptor.GetEditor(Type)

如需這個成員的說明,請參閱 GetEditor(Type)

ICustomTypeDescriptor.GetEvents()

如需這個成員的說明,請參閱 GetEvents()

ICustomTypeDescriptor.GetEvents(Attribute[])

如需這個成員的說明,請參閱 GetEvents(Attribute[])

ICustomTypeDescriptor.GetProperties()

如需這個成員的說明,請參閱 GetProperties()

ICustomTypeDescriptor.GetProperties(Attribute[])

如需這個成員的說明,請參閱 GetProperties(Attribute[])

ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

如需這個成員的說明,請參閱 GetPropertyOwner(PropertyDescriptor)

IStateManager.IsTrackingViewState

取得值,指出伺服器控制項是否正在追蹤其檢視狀態變更。

(繼承來源 Style)
IStateManager.LoadViewState(Object)

載入先前儲存的狀態。

(繼承來源 Style)
IStateManager.SaveViewState()

傳回包含狀態變更的物件。

(繼承來源 Style)
IStateManager.TrackViewState()

啟動追蹤狀態的變更。

(繼承來源 Style)

適用於

另請參閱