Menu.DynamicSelectedStyle 屬性

定義

取得 MenuItemStyle 物件的參考,這個物件可讓您設定使用者選取之動態功能表項目的外觀。

public:
 property System::Web::UI::WebControls::MenuItemStyle ^ DynamicSelectedStyle { System::Web::UI::WebControls::MenuItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.MenuItemStyle DynamicSelectedStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.DynamicSelectedStyle : System.Web.UI.WebControls.MenuItemStyle
Public ReadOnly Property DynamicSelectedStyle As MenuItemStyle

屬性值

MenuItemStyle 的參考,代表已選取動態功能表項目的外觀。

屬性

範例

下列程式碼範例示範如何使用 DynamicSelectedStyle 屬性來指定所選動態功能表項目的淺藍色背景色彩。


<%@ 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 DynamicSelectedStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu DynamicSelectedStyle Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="1"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"
        runat="server">
        
        <dynamicselectedstyle backcolor="LightBlue"
          borderstyle="Solid"
          bordercolor="Black"
          borderwidth="1"/>
      
        <items>
          <asp:menuitem text="Home"
            tooltip="Home">
            <asp:menuitem text="Music"
              tooltip="Music">
              <asp:menuitem text="Classical"
                tooltip="Classical"/>
              <asp:menuitem text="Rock"
                tooltip="Rock"/>
              <asp:menuitem text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem text="Movies"
              tooltip="Movies">
              <asp:menuitem text="Action"
                tooltip="Action"/>
              <asp:menuitem text="Drama"
                tooltip="Drama"/>
              <asp:menuitem 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 DynamicSelectedStyle Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>Menu DynamicSelectedStyle Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="1"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"
        runat="server">
        
        <dynamicselectedstyle backcolor="LightBlue"
          borderstyle="Solid"
          bordercolor="Black"
          borderwidth="1"/>
      
        <items>
          <asp:menuitem text="Home"
            tooltip="Home">
            <asp:menuitem text="Music"
              tooltip="Music">
              <asp:menuitem text="Classical"
                tooltip="Classical"/>
              <asp:menuitem text="Rock"
                tooltip="Rock"/>
              <asp:menuitem text="Jazz"
                tooltip="Jazz"/>
            </asp:menuitem>
            <asp:menuitem text="Movies"
              tooltip="Movies">
              <asp:menuitem text="Action"
                tooltip="Action"/>
              <asp:menuitem text="Drama"
                tooltip="Drama"/>
              <asp:menuitem text="Musical"
                tooltip="Musical"/>
            </asp:menuitem>
          </asp:menuitem>
        </items>
      
      </asp:menu>

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

備註

DynamicSelectedStyle當使用者從功能表選取動態功能表項目時,請使用 屬性來控制動態功能表項目的外觀。 此屬性是唯讀的;不過,您可以設定其傳回之 MenuItemStyle 物件的屬性。 屬性可以宣告方式設定在 表單 Property-Subproperty 中,其中 Subproperty 是 物件 (MenuItemStyle 的屬性, DynamicSelectedStyle-ForeColor 例如,) 。 屬性也可以在表單 Property.Subproperty 中以程式設計方式設定,例如, DynamicSelectedStyle.ForeColor) (。

動態功能表項目的樣式屬性會依下列順序套用:

  1. DynamicMenuStyle.

  2. DynamicMenuItemStyle. LevelMenuItemStyles如果已定義集合或 LevelSubMenuStyles 集合,則此時會套用該集合,並覆寫其他功能表項目樣式屬性。

  3. DynamicSelectedStyle. LevelSelectedStyles如果已定義集合,則此時會套用該集合,並覆寫其他功能表項目樣式屬性。

  4. DynamicHoverStyle.

適用於

另請參閱