Skip to main content
Tab

NavBarGroup.ContentTemplate Property

Gets or sets a template used for displaying the client region’s content of the current group.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(null)]
public virtual ITemplate ContentTemplate { 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 group’s client region.

Remarks

Use the ContentTemplate property to define the content for the client region of the current group. A group’s client region is considered to be an area where group items are displayed - it doesn’t involve the group’s header. The template created using the ContentTemplate property fills the group’s entire client region.

The ContentTemplate property is useful when it is required to display a specific control within a navbar group. Placing a control onto the template container causes the control to be displayed within the group, when it is expanded.

Note that any style settings defined for the group’s client region via the specific properties (such as the ASPxNavBar.GroupContentStyle or NavBarGroup.ContentStyle) are still in effect for the group whose client content is specified using the ContentTemplate property.

The content of client regions of all navbar groups can be defined using the navbar’s ASPxNavBar.GroupContentTemplate property.

Note

Once a template defined via the ContentTemplate 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

public partial class ASPxperience_LoadOnCallback : System.Web.UI.Page {
     protected void LoadGroupContent(NavBarGroup group) {
         Control control = null;
         if(group.Expanded && group.ContentTemplate == null) {
             switch(group.Name) {
                 case "Group1":
                 case "Group2":
                     control = LoadControl("UserControl.ascx");
                     break;
             }
             group.ContentTemplate = control as ITemplate;
         }
     }
     protected void LoadExpandedGroups() {
         for(int i = 0; i < ASPxNavBar1.Groups.Count; i++)
             LoadGroupContent(ASPxNavBar1.Groups[i]);
     }

     protected void Page_Load(object sender, EventArgs e) {
         LoadExpandedGroups();
     }
     protected void ASPxNavBar1_ExpandedChanged(object source, 
     DevExpress.Web.NavBarGroupEventArgs e) {
         LoadGroupContent(e.Group);
     }
}
See Also