Skip to main content

MenuItem.Text Property

Gets or sets the text content of the current menu item.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web


public string Text { get; set; }

Property Value

Type Default Description
String "Item"

A string value that specifies the text content of the MenuItem.


Use the Text property to specify the current menu item’s text content. The position of the text within items is specified by the AppearanceStyleBase.HorizontalAlign and AppearanceStyleBase.VerticalAlign properties available via the corresponding style properties of a menu control or a menu item object.

If the MenuItem.NavigateUrl property of a menu item is assigned, the item serves as a hyperlink and the appearance of the item’s text set by the Text property can be controlled via the ASPxMenuBase.LinkStyle property.

In addition to the text, you can specify a menu item’s image and hint text using the MenuItem.Image and MenuItem.ToolTip properties respectively.


If the Text property is empty and an item image is specified, a text element markup is not rendered. In this case, it is impossible to set a text on the client side using the ASPxClientMenuItem.SetText method.


This sample shows how to bind the ASPxMenu to data stored in a database.

View Example

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class ASPxperience_Menu_BuildMenuFromDB_BuildMenuFromDB : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
        BuildMenu(ASPxMenu1, AccessDataSource1);

    protected void BuildMenu(DevExpress.Web.ASPxMenu.ASPxMenu menu, SqlDataSource dataSource) {
        // Get DataView
        DataSourceSelectArguments arg = new DataSourceSelectArguments();
        DataView dataView = dataSource.Select(arg) as DataView;
        dataView.Sort = "ParentID";

        // Build Menu Items
        Dictionary<string, DevExpress.Web.ASPxMenu.MenuItem> menuItems =
            new Dictionary<string, DevExpress.Web.ASPxMenu.MenuItem>();

        for (int i = 0; i < dataView.Count; i++) {
            DataRow row = dataView[i].Row;
            DevExpress.Web.ASPxMenu.MenuItem item = CreateMenuItem(row);
            string itemID = row["ID"].ToString();
            string parentID = row["ParentID"].ToString();

            if (menuItems.ContainsKey(parentID))
            else {
                if (parentID == "0") // It's Root Item
            menuItems.Add(itemID, item);

    private DevExpress.Web.ASPxMenu.MenuItem CreateMenuItem(DataRow row) {
        DevExpress.Web.ASPxMenu.MenuItem ret = new DevExpress.Web.ASPxMenu.MenuItem();
        ret.Text = row["Text"].ToString();
        ret.NavigateUrl = row["NavigateUrl"].ToString();
        return ret;

The following code snippets (auto-collected from DevExpress Examples) contain references to the Text property.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also