Menu.LevelSelectedStyles Property
Assembly: System.Web (in system.web.dll)
Use the LevelSelectedStyles collection as an alternative to the DynamicSelectedStyle and StaticSelectedStyle properties to control the style of a selected menu item at the individual levels of the menu. The styles contained in this collection are applied to a selected menu item based on its menu level. The first style in the collection corresponds to the style of a selected menu item in the first level of the menu. The second style in the collection corresponds to the style of a selected menu item in the second level of the 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.
Note |
|---|
| If a style is defined for a certain level using the LevelSelectedStyles collection, this overrides the DynamicSelectedStyle and StaticSelectedStyle properties at that level. |
The following code example demonstrates how to use the LevelSelectedStyles collection to apply a style setting to the selected menu item in a Menu control based on its level.
<%@ Page Language="C#" %> <html> <body> <form runat="server"> <h3>Menu LevelMenuItemStyles and LevelSelectedStyles Example</h3> <asp:menu id="NavigationMenu" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Vertical" target="_blank" runat="server"> <levelmenuitemstyles> <asp:menuitemstyle BackColor="LightSteelBlue" forecolor="Black"/> <asp:menuitemstyle BackColor="SkyBlue" forecolor="Black"/> <asp:menuitemstyle BackColor="LightSkyBlue" forecolor="Black"/> </levelmenuitemstyles> <levelselectedstyles> <asp:menuitemstyle BackColor="Cyan" forecolor="Gray"/> <asp:menuitemstyle BackColor="LightCyan" forecolor="Gray"/> <asp:menuitemstyle BackColor="PaleTurquoise" forecolor="Gray"/> </levelselectedstyles> <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>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Reference
Menu ClassMenu Members
System.Web.UI.WebControls Namespace
Menu.DynamicHoverStyle Property
Menu.DynamicMenuItemStyle Property
Menu.DynamicMenuStyle Property
Menu.DynamicSelectedStyle Property
Menu.LevelMenuItemStyles Property
LevelSubMenuStyles
StaticHoverStyle
StaticMenuItemStyle
StaticMenuStyle
StaticSelectedStyle
Note