Tab
A newer version of this page is available. Switch to the current version.

ASPxMenu Class

A menu control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.1.dll

Declaration

public class ASPxMenu :
    ASPxMenuBase

The following members accept/return ASPxMenu objects:

Remarks

The ASPxMenu allows you to display a menu in your web application. You can use the menu control in combination with a site map data source control (for instance, the ASPxSiteMapDataSource) to navigate a web site.

Create a Menu

Design Time

The ASPxMenu control is available on the DX.19.1: Navigation & Layout toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize control settings, or paste the control markup in the page’s source code.

<dx:ASPxMenu ID="mMain" runat="server" AllowSelectItem="True" ShowPopOutImages="True">
    <Items>
        <dx:MenuItem Text="Home">
            <Items>
                <dx:MenuItem Text="News">
                    <Items>
                        <dx:MenuItem Text="For Developers">
                        </dx:MenuItem>
                        <dx:MenuItem Text="Website news">
                        </dx:MenuItem>
                    </Items>
                </dx:MenuItem>
                <dx:MenuItem Text="Our Mission">
                </dx:MenuItem>
                <dx:MenuItem Text="Our Customers">
                </dx:MenuItem>
            </Items>
        </dx:MenuItem>
        ...
    </Items>
</dx:ASPxMenu>

Run Time

protected void Page_Load(object sender, EventArgs e) {
ASPxMenu ASPxMenu1 = new ASPxMenu()
{
    ID = "ASPxMenu1",
    ItemAutoWidth = false,
    AllowSelectItem = true
};
ASPxMenu1.Items.Add(
    new DevExpress.Web.MenuItem()
    {
        Text = "Home",
        Items = {
            new DevExpress.Web.MenuItem() {Text = "News"},
            new DevExpress.Web.MenuItem() {Text = "Our Mission"},
            new DevExpress.Web.MenuItem() {Text = "Our Customers"}
        }
    });
ASPxMenu1.Items.Add(new DevExpress.Web.MenuItem() { Text = "Products" });
...
form1.Controls.Add(ASPxMenu1);
}

Client-Side API

The ASPxMenu‘s client-side API is implemented with JavaScript language and exposed by the ASPxClientMenu object.

Availability

Available by default.

Class name

ASPxClientMenu

Access name

ClientInstanceName

Events

ASPxMenu.ClientSideEvents

Features

Tree Structure

The ASPxMenu control can contain the following menu items types:

  • root menu items - a menu item located at the menu’s top level (level 0).

  • child menu item - a menu item that has a parent menu item.

The menu stores its root items in the ASPxMenuBase.Items collection. Child menu items are stored in the parent menu item’s MenuItem.Items collection.

The submenu items appear and disappear when an end user clicks outside the menu or according to the ASPxMenuBase.AppearAfter and ASPxMenuBase.DisappearAfter settings.

<dx:ASPxMenu ID="mMain" runat="server" AllowSelectItem="True" ShowPopOutImages="True">
    <Items>
        <dx:MenuItem Text="Home">
            <Items>
                <dx:MenuItem Text="News">
                    <Items>
                        <dx:MenuItem Text="For Developers">
                        </dx:MenuItem>
                        <dx:MenuItem Text="Website news">
                        </dx:MenuItem>
                    </Items>
                </dx:MenuItem>
                <dx:MenuItem Text="Our Mission">
                </dx:MenuItem>
                <dx:MenuItem Text="Our Customers">
                </dx:MenuItem>
            </Items>
        </dx:MenuItem>
    ...
    </Items>
</dx:ASPxMenu>

See demo

Data Binding

You can bind the menu control’s items to hierarchal data sources - ASPxHierarchicalDataWebControl.DataSourceID, ASPxDataWebControlBase.DataSource. Use ASPxMenuBase.ItemDataBound event to dynamically map menu items’ properties to the required data fields.

    <dx:ASPxMenu ID="ASPxMenu1" runat="server"
    DataSourceID="ASPxSiteMapDataSource1" OnItemDataBound="ASPxMenu1_ItemDataBound"
    EncodeHtml="False" AllowSelectItem="True" Orientation="Vertical" />

Learn more | See demo

Scrolling

The menu control allows you to scroll items in sub menus if item heights exceed the browser window’s height.

Property

Description

EnableSubMenuScrolling

Specifies whether submenu scrolling is enabled in the menu.

EnableScrolling

Specifies whether submenu scrolling is enabled in an individual menu item.

ScrollDownButtonImage, ScrollUpButtonIma