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

MenuItem.Template Property

Gets or sets a template used to display the content of the current menu item.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

[DefaultValue(null)]
public virtual ITemplate Template { get; set; }
<DefaultValue(Nothing)>
Public Overridable Property Template As ITemplate

Property Value

Type Default Description
ITemplate

null

An object supporting the System.Web.UI.ITemplate interface which contains the template used to display the menu item's content.

Remarks

Use the Template property to control the contents of the current menu item. The template defined using this property replaces the content of an individual menu item - in particular, the specified image and text of the item.

Note that any style settings defined for the menu item via specific properties (such as the ASPxMenuBase.ItemStyle or ASPxMenuBase.SubMenuItemStyle, etc) are still in effect for the menu item whose content is specified through using the Template property.

In order to define a common content for all menu items within a menu control, the menu's ASPxMenuBase.ItemTemplate property can be used. 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 Template property is created within a tab 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

A Template cannot contain another menu control.

Examples

This part of the Templates demo illustrates how to use template technology within the ASPxMenu control.

A specific MenuItem.SubMenuTemplate property is used to define the template for the first root menu item's submenu. The content of a SubMenuTemplate type is represented by the ASPxSiteMapControl, which displays a hierarchical structure of links (site map nodes) that reference different web pages within the site.

The appearance of the second root menu item's sub-item is defined via the MenuItem.Template property of each sub-item.

<dxm:ASPxMenu BorderBetweenItemAndSubMenu="HideRootOnly" EnableViewState="False" 
EnableClientSideAPI="true" ID="ASPxMenu1" AutoSeparators="None" runat="server" 
ShowSubMenuShadow="true" ItemImagePosition="Right" GutterWidth="0px" 
ShowPopOutImages="True">
    <Items>
        <dxm:MenuItem Text="SubMenu Template" Name="submenu">
        <Items>
            <dxm:MenuItem />
        </Items>             
        <SubMenuTemplate>
            <dxsm: