Menu.StaticHoverStyle 屬性

定義

取得 Style 物件的參考,這個物件可讓您設定當滑鼠指標位於靜態功能表項目上時,靜態功能表項目的外觀。

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

屬性值

Style

Style 的參考,代表當滑鼠指標位於靜態功能表項目上時,靜態功能表項目的樣式。

屬性

範例

下列程式碼範例示範如何使用 StaticHoverStyle 屬性,在使用者將滑鼠指標放在它上方時,將靜態功能表項目的背景色彩變更為淺藍色。


<%@ 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" >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu StaticHoverStyle Example</title>
</head>

  <body>
    <form id="form1" runat="server">
    
      <h3>Menu StaticHoverStyle Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <statichoverstyle backcolor="LightSkyBlue"
          forecolor="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" >

  <!-- For the hover styles of the Menu control to  -->
  <!-- work correctly, you must include this head   -->
  <!-- element.                                     -->
  <head runat="server">
    <title>Menu StaticHoverStyle Example</title>
</head>

  <body>
    <form id="form1" runat="server">
    
      <h3>Menu StaticHoverStyle Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <statichoverstyle backcolor="LightSkyBlue"
          forecolor="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>

備註

StaticHoverStyle當滑鼠指標放在靜態功能表項目上方時,請使用 屬性來控制靜態功能表項目的外觀。 此屬性是唯讀的;不過,您可以設定其傳回之 Style 物件的屬性。 屬性可以宣告方式設定在 表單 Property-Subproperty 中,其中 Subproperty 是 物件 (Style 的屬性, StaticHoverStyle-ForeColor 例如,) 。 屬性也可以在表單 Property.Subproperty 中以程式設計方式設定,例如, StaticHoverStyle.ForeColor) (。

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

  1. StaticMenuStyle.

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

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

  4. StaticHoverStyle.

適用於

另請參閱