Menu.DynamicHoverStyle 属性

定义

获取对 Style 对象的引用,使用该对象可以设置鼠标指针置于动态菜单项上时的菜单项外观。

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

属性值

Style 对象的引用,该对象表示鼠标指针置于动态菜单项上时的菜单项样式。

属性

示例

下面的代码示例演示如何在用户将鼠标指针放在动态菜单项上时使用 DynamicHoverStyle 属性将动态菜单项的背景色更改为浅蓝色。


<%@ 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 DynamicHoverStyle Example</title>
</head>

  <body>
    <form id="form1" runat="server">
    
      <h3>Menu DynamicHoverStyle Example</h3>
    
      <asp:menu id="NavigationMenu"
        staticdisplaylevels="2"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">
        
        <dynamichoverstyle 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 DynamicHoverStyle Example</title>
</head>

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

注解

DynamicHoverStyle当鼠标指针位于动态菜单项上时,使用 属性控制动态菜单项的外观。 此属性是只读的;但是,可以设置它返回的对象 Style 的属性。 属性可以在 窗体 Property-Subproperty中以声明方式设置,其中 Subproperty 是 对象的属性 Style (例如 DynamicHoverStyle-ForeColor ,) 。 还可以在窗体 Property.Subproperty 中以编程方式设置属性 (例如 DynamicHoverStyle.ForeColor ,) 。

动态菜单项的样式属性按以下顺序应用:

  1. DynamicMenuStyle.

  2. DynamicMenuItemStyle. LevelMenuItemStyles如果定义了集合或LevelSubMenuStyles集合,则此时会应用它,覆盖其他菜单项样式属性。

  3. DynamicSelectedStyle. LevelSelectedStyles如果定义了集合,则此时会应用该集合,覆盖其他菜单项样式属性。

  4. DynamicHoverStyle.

适用于

另请参阅