Back to Devexpress

ASPxNavBar.GroupHeaderTemplate Property

aspnet-devexpress-dot-web-dot-aspxnavbar-e1ca69df.md

latest4.7 KB
Original Source

ASPxNavBar.GroupHeaderTemplate Property

Gets or sets a common template used for displaying the content of all group headers within the navbar control.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

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

Property Value

TypeDefaultDescription
ITemplatenull

An object supporting the System.Web.UI.ITemplate interface, which contains the template used for displaying the content of all group headers within the navbar.

|

Remarks

Use the GroupHeaderTemplate property to define a common content for all group headers within the current navbar control. The template created using this property replaces the content of each header within the navbar - in particular, the image and text associated with the header.

Note that any style settings defined for the group headers via the specific properties (such as the ASPxNavBar.GroupHeaderStyle or NavBarGroup.HeaderStyle) are still in effect for the headers whose contents are specified by using the GroupHeaderTemplate property.

The content of a particular group’s header can be defined using the group’s NavBarGroup.HeaderTemplate property.

Note

Once a template defined via the GroupHeaderTemplate property is created within a control, it is instantiated within a container object of the NavBarGroupTemplateContainer 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 to modify the ASPxNavBar‘s group header content.

csharp
using DevExpress.Web.ASPxNavBar;
...
protected void Page_Load(object sender, EventArgs e) {
     NavBarGroup group1 = new NavBarGroup("group1", "group1");
     NavBarItem item1 = new NavBarItem("item1", "item1");

     ASPxNavBar1.Groups.Add(group1);
     group1.Items.Add(item1);

     ASPxNavBar1.GroupHeaderTemplate= new MyTemplate();
     ASPxNavBar1.GroupHeaderTemplateCollapsed = new MyTemplate1();
}

public class MyTemplate : ITemplate {
     void ITemplate.InstantiateIn(Control container) {
          Label label = new Label();
          label.Text = "The group is expanded";
          container.Controls.Add(label);
     }
}

public class MyTemplate1 : ITemplate {
     void ITemplate.InstantiateIn(Control container) {
          Label label2 = new Label();
          label2.Text = "The group is collapsed";
          container.Controls.Add(label2);
     }
}
vb
Imports DevExpress.Web.ASPxNavBar
... 
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
     Dim group1 As New NavBarGroup("group1", "group1")
     Dim item1 As New NavBarItem("item1", "item1")

     ASPxNavBar1.Groups.Add(group1)
     group1.Items.Add(item1)

     ASPxNavBar1.GroupHeaderTemplate= New MyTemplate()
     ASPxNavBar1.GroupHeaderTemplateCollapsed = New MyTemplate1()
End Sub

Public Class MyTemplate
     Implements ITemplate
     Private Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
          Dim label As New Label()
          label.Text = "The group is expanded"
          container.Controls.Add(label)
     End Sub
End Class

Public Class MyTemplate1
     Implements ITemplate
     Private Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
          Dim label2 As New Label()
          label2.Text = "The group is collapsed"
          container.Controls.Add(label2)
     End Sub
End Class

See Also

GroupHeaderTemplateCollapsed

HeaderTemplate

Navigation Bar

ASPxNavBar Class

ASPxNavBar Members

DevExpress.Web Namespace