Skip to main content
.NET Framework 4.5.2+
  • The page you are viewing does not exist in the .NET Standard 2.0+ platform documentation. This link will take you to the parent topic of the current section.
  • The page you are viewing does not exist in the .NET 6.0+ platform documentation. This link will take you to the parent topic of the current section.

BaseXafPage.CustomizeTemplateContent Event

Occurs when the template content is created.

Namespace: DevExpress.ExpressApp.Web.Templates

Assembly: DevExpress.ExpressApp.Web.v23.1.dll

NuGet Package: DevExpress.ExpressApp.Web


public event EventHandler<CustomizeTemplateContentEventArgs> CustomizeTemplateContent

Event Data

The CustomizeTemplateContent event's data class is CustomizeTemplateContentEventArgs. The following properties provide information specific to this event:

Property Description
TemplateContent Gets a User Control that specifies the BaseXafPage page’s content.


Handle this event to customize template content. For instance, you can change the application logo displayed in the top-left corner.


The CustomizeTemplateContent event is not designed for in-depth template customization. Instead, use the approach described at How to: Customize an ASP.NET Web Forms Template topic.

Open the Default.aspx.cs (Default.aspx.vb) file and add the Page_Init method to the Default class to handle the Page.Init event, and then subscribe to the CustomizeTemplateContent event. Use the CustomizeTemplateContentEventArgs.TemplateContent parameter or BaseXafPage.TemplateContent property to access the template content. The template content exposes the required Image control via the HeaderImageControl property.

protected void Page_Init() {
    CustomizeTemplateContent += delegate(object sender, CustomizeTemplateContentEventArgs e) {
        DefaultVerticalTemplateContent content = TemplateContent as DefaultVerticalTemplateContent;
        if (content == null) return;
        content.HeaderImageControl.DefaultThemeImageLocation = "~/Images";
        content.HeaderImageControl.ImageName = "CustomLogo.png";

With this code, the application logo will be loaded from the CustomLogo.png file located in the Images folder of the ASP.NET Web Forms application project.

The image is specified by the DefaultThemeImageLocation and ImageName properties of the ThemedImageControl, located on the main window Template. The ImageName property specifies the Logo image name and the DefaultThemeImageLocation attribute specifies the location where XAF searches for this image. The following list explains how these property values are treated.

  1. If the DefaultThemeImageLocation attribute value begins with a tilde character (“~”), it is treated as a relative path to the image specified by the ImageName attribute.
  2. If the DefaultThemeImageLocation attribute value does not begin with a tilde character, this value is concatenated with the ImageName attribute value. The concatenation result is treated as the name of a resource from the DevExpress.Web.ASPxThemes.23.1.dll.
  3. If the DefaultThemeImageLocation attribute value is not specified or is an empty string, then the ImageName attribute value is treated as the name of a resource image without the extension (an example is available in the Change an Application Logo and Info topic).

You can access other controls of a template in a similar way. If a control is not directly exposed, use the Control.FindControl to search for it. Review the template’s *.ascx file to determine the ID of the necessary control. You can find the ascx files at %PROGRAMFILES%\DevExpress 23.1\Components\Sources\DevExpress.ExpressApp\DevExpress.ExpressApp.Web\Resources\.

If modifying the Default.aspx.cs (Default.aspx.vb) source is not appropriate in your scenario, e.g., you want to access the template content from a module, handle the XafApplication.CustomizeTemplate event. Get the BaseXafPage object by casting the CustomizeTemplateEventArgs.Template parameter to the BaseXafPage type and then subscribe to the CustomizeTemplateContent event.

Instead of handling the CustomizeTemplateContent event, you can apply a custom template and modify the ThemedImageControl element in the following manner.

<cc4:ThemedImageControl ID="TIC" DefaultThemeImageLocation="~/Images/"
    ImageName="CustomLogo.png" BorderWidth="0px" runat="server" />
See Also