Skip to main content
Tab

ASPxMenuBase.ItemTemplate Property

Gets or sets a common template used for displaying the content of all menu items within a menu control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.1.dll

Declaration

[DefaultValue(null)]
public virtual ITemplate ItemTemplate { get; set; }

Property Value

Type Default Description
ITemplate null

An object supporting the System.Web.UI.ITemplate interface which contains the template used for displaying the content of all menu items within a menu.

Remarks

Use the ItemTemplate property to define a common content for all menu items within a menu control (which can be either the ASPxMenu or ASPxPopupMenu). The template created using this property replaces the content of each menu item within the menu - in particular, the item’s image and the specified text.

Note that any style settings defined for the menu items via specific properties (such as the ASPxMenuBase.ItemStyle or ASPxMenuBase.SubMenuItemStyle, etc) are still in effect for the menu items whose contents are specified via the ItemTemplate property.

The content of an individual menu item can be defined using the item’s MenuItem.Template property. A template for the client regions of submenus can be specified via the ASPxMenuBase.SubMenuTemplate or MenuItem.SubMenuTemplate properties.

Note

Once a template defined via the ItemTemplate property is created within a control, it is instantiated within a container object of the MenuItemTemplateContainer type. This container object exposes a set of specific properties to which the template’s child controls can be bound.

Note

An ItemTemplate cannot contain another menu control.

Example

This sample illustrates how to keep the NavigateUrl of the item if there's a control in the ItemTemplateContainer of the ASPxMenu.

View Example

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication6._Default" %>

<%@ register Assembly="DevExpress.Web.ASPxEditors.v8.3" Namespace="DevExpress.Web.ASPxEditors"
    TagPrefix="dxe" %>

<%@ register Assembly="DevExpress.Web.v8.3" Namespace="DevExpress.Web.ASPxMenu" TagPrefix="dxm" %>
<%@ register Assembly="DevExpress.Web.v8.3" Namespace="DevExpress.Web.ASPxSiteMapControl"
    TagPrefix="dxsm" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <dxm:aspxmenu ID="ASPxMenu1" runat="server" DataSourceID="ASPxSiteMapDataSource1"
            Orientation="Vertical" OnDataBound="ASPxMenu1_DataBound">
            <itemtemplate>
                <dxe:aspxlabel ID="ASPxLabel1" runat="server" Text='<%#Container.Item.Text %>' Width="100px" Height="20px" Cursor="pointer">
                </dxe:aspxlabel>
            </itemtemplate>
        </dxm:aspxmenu>
        <dxsm:aspxsitemapdatasource ID="ASPxSiteMapDataSource1" runat="server" SiteMapFileName="~/web.sitemap" />

    </div>
    </form>
</body>
</html>
See Also