Export (0) Print
Expand All
Expand Minimize

Menu.LevelSubMenuStyles Property

Gets a MenuItemStyleCollection object that contains the style settings that are applied to the submenu items in the static menu based on their level in a Menu control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
public SubMenuStyleCollection LevelSubMenuStyles { get; }

Property Value

Type: System.Web.UI.WebControls.SubMenuStyleCollection
A MenuItemStyleCollection that contains the style settings that are applied to the submenu items in the static menu based on their level in a Menu control.

Use the LevelSubMenuStyles collection as an alternative to the individual style properties (such as StaticMenuItemStyle) to control the style of the static submenu items displayed in the static menu at the individual levels. The styles contained in this collection are applied to the static submenu items based on their menu level. The first style in the collection corresponds to the style of the first static submenu level displayed in the static menu. The second style in the collection corresponds to the style of the second submenu level displayed in the static menu, and so on. This collection is most often used to generate table of contents-style navigation menus where menu items at a certain level should have the same appearance, regardless of whether they have submenus.

NoteNote

If a style is defined for a certain level using the LevelSubMenuStyles collection, this overrides any static submenu item style settings at that level.

The following code example demonstrates how to use the LevelSubMenuStyles collection to apply style settings to the submenu items displayed in the static menu of a Menu control based on their level.


<%@ 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 LevelSubMenuStyles</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>Menu LevelSubMenuStyles</h3>

      <asp:menu id="NavigationMenu"
        staticdisplaylevels="3"
        staticsubmenuindent="10" 
        orientation="Vertical"
        target="_blank"  
        runat="server">

        <levelsubmenustyles>
          <asp:submenustyle backcolor="LightSteelBlue"
            forecolor="Black"/>
          <asp:submenustyle backcolor="SkyBlue"
            forecolor="Gray"/>          
        </levelsubmenustyles>  

        <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>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft