Back to Devexpress

Apply a Theme with the DevExpress Mechanism

aspnet-11724-common-concepts-appearance-customization-theming-apply-a-theme-with-the-devexpress-mechanism.md

latest2.8 KB
Original Source

Apply a Theme with the DevExpress Mechanism

  • Jun 21, 2024
  • 3 minutes to read

DevExpress provides an easy way to theme your web application via a theme stored in a specific assembly.

If you use a pre-packaged theme assembly (ASPxThemes), you are not required to copy theme-related files to the project. All required theme resource files (such as image, CSS and skin files) will automatically be obtained from the theme assembly. To apply a theme from a custom assembly, add an assembly reference to the project and register the assembly in the Web.config file.

To apply a theme, specify the theme name for a website, a web page or an individual DevExpress control - as described in the corresponding section below.

Apply a Theme to a Control

  • At design time:

  • At runtime:

Apply a Theme to a Web Page

  • At runtime:

Apply a Theme to a Website

  • At design time:

  • At runtime:

Note

You can use the Project Wizard to specify a theme for your site. This wizard sets the Theme Name attribute in the Web.config file. If a custom theme is specified, the wizard adds a reference to the theme assembly and sets the customThemeAssemblies attribute in the Web.config file.

Apply a Theme to a Sharepoint Web Part

When working with Sharepoint WebPart / VisualWebPart modules, override the CreateChildControls method to apply a theme – as shown below.

csharp
public class WEB_PART_OR_VISUAL_WEB_PART_CLASS_HERE : WebPart {
    protected override void CreateChildControls() {
        DevExpress.Web.ASPxWebControl.GlobalTheme = "Aqua";
        ...
        //Create Child Controls Here
    }
}
vb
Public Class WEB_PART_OR_VISUAL_WEB_PART_CLASS_HERE
    Inherits WebPart
    Protected Overrides Sub CreateChildControls()
        DevExpress.Web.ASPxWebControl.GlobalTheme = "Aqua"
       ...
        'Create Child Controls Here
    End Sub
End Class

See Also

Apply a Theme with the ASP.NET Mechanism

Attach a Custom Theme Assembly