Export (0) Print
Expand All

SubMenuStyleCollection Class

Represents a collection of SubMenuStyle objects in a Menu control.

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

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class SubMenuStyleCollection : StateManagedCollection

The SubMenuStyleCollection class is used to store and manage a collection of SubMenuStyle objects in a Menu control. The Menu control uses the SubMenuStyleCollection class as the underlying data type of the LevelSubMenuStyles property.

The LevelSubMenuStyles property provides additional style choices in addition to the StaticMenuStyle and DynamicMenuStyle properties. The first style in the SubMenuStyleCollection collection corresponds to the submenu style for the first level of the menu. The second style in the collection corresponds to the submenu style for the second level of the menu, and so on. The LevelSubMenuStyles property is most often used to generate a navigation menu, like a Web site map, where menu items at a certain level should have the same appearance, regardless of whether they have submenus.

The SubMenuStyleCollection class inherits most of its members from the StateManagedCollection class. For more information on the inherited members, see the StateManagedCollection collection.

The following example demonstrates how to use the SubMenuStyleCollection class to specify the style settings for the submenus in a Menu control based on the submenu's level. In this example, the LevelSubMenuStyles property returns a SubMenuStyleCollection object.

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

System.Object
  System.Web.UI.StateManagedCollection
    System.Web.UI.WebControls.SubMenuStyleCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft