Skip to main content
A newer version of this page is available. .
Tab

NavBarItem.Template Property

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

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(null)]
public virtual ITemplate Template { 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 item’s content.

Remarks

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

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

In order to define the common content for all items within a navbar control, the navbar’s ASPxNavBar.ItemTemplate property can be used. A template for items of a particular group can be specified via the NavBarGroup.ItemTemplate property.

Note

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

Example

This example demonstrates how the ASPxNavBar.GroupDataBound and the ASPxNavBar.ItemDataBound events can be used.

protected void ASPxNavBar1_GroupDataBound(object source, DevExpress.Web.NavBarGroupEventArgs e) {
     NavBarItem btnItem = e.Group.Items.Add();
     btnItem.Template = LoadControl("ContentTemplate.ascx") as ITemplate;
}
protected void ASPxNavBar1_ItemDataBound(object source, NavBarItemEventArgs e) {
     if (e.Item.Text == "Canon EOS 400D") {
          e.Item.Text = e.Item.Text + " (New model)"; 
     }
}
See Also