Skip to main content
All docs
V24.2

DxResourceManager Class

Contains methods that allow you to register DevExpress client resources and/or custom scripts.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.Resources.v24.2.dll

NuGet Package: DevExpress.Blazor.Resources

Declaration

public static class DxResourceManager

Remarks

If you use a DevExpress Blazor project template, your application automatically registers all scripts DevExpress libraries require. If you use other Blazor applications, you need to register those scripts. Call the DxResourceManager.RegisterScripts method in the Components/App.razor file:

<head>
    @*...*@
    @DxResourceManager.RegisterScripts()
</head>

DevExpress Resources

The Resource Manager automatically registers client DevExpress resources based on installed NuGet packages. For instance, if your project includes the DevExpress.Blazor.RichEdit package, the method registers scripts required for the Rich Text Editor component.

The Resource Manager allows you to replace some DevExpress resources with their custom versions. For instance, you can register a specific version of the jQuery script or use a custom DevExtreme bundle. The following table lists DevExpress resources that you can replace, their positions among other scripts, and NuGet packages that include these scripts:

Position

DevExpress Resource

NuGet Packages

0

CommonResources.KnockoutJS

DevExpress.Blazor.Dashboard
DevExpress.Blazor.Reporting.JSBasedControls

150

BlazorResources.QuillJS

DevExpress.Blazor

200

CommonResources.DevExtremeJS

DevExpress.Blazor
DevExpress.Blazor.Dashboard
DevExpress.Blazor.Reporting.JSBasedControls
DevExpress.Blazor.RichEdit

300

CommonResources.JQueryJS

DevExpress.Blazor.Dashboard
DevExpress.Blazor.Reporting.JSBasedControls

400

CommonResources.AceJS

DevExpress.Blazor.Dashboard
DevExpress.Blazor.Reporting.JSBasedControls

500

CommonResources.AceLanguageToolsJS

DevExpress.Blazor.Dashboard
DevExpress.Blazor.Reporting.JSBasedControls

600

CommonResources.AnalyticsJS

DevExpress.Blazor.Dashboard
DevExpress.Blazor.Reporting.JSBasedControls

700

JSBasedReportingResources.WebDocumentViewerJS

DevExpress.Blazor.Reporting.JSBasedControls

700

CommonResources.QueryBuilderJS

DevExpress.Blazor.Dashboard
DevExpress.Blazor.Reporting.JSBasedControls

800

JSBasedReportingResources.ReportDesignerJS

DevExpress.Blazor.Reporting.JSBasedControls

800

DashboardResources.DashboardJS

DevExpress.Blazor.Dashboard

Follow the steps below to register a custom version of a DevExpress resource:

  1. Pass the resource to the Unregister method to prevent the Resource Manager from loading this script.
  2. Call the Register method to register a custom version of this script. Note that the script should have the same Position as the corresponding standard resource.

The following example replaces the standard DevExtremeJS script with its custom version:

@DxResourceManager.RegisterScripts((config) => {
    config.Unregister(CommonResources.DevExtremeJS);
    config.Register(new DxResource("dx.all.js", CommonResource.DevExtremeJS.Position));
})

Custom Scripts

Call the Register method to register a non-DevExpress script globally. Note that you should register custom scripts after DevExpress resources.

@DxResourceManager.RegisterScripts((config) => {
    config.Register(new DxResource("script.js", CommonResources.DevExtremeJS.Position + 1));
})

Call the LoadDxResources(IJSRuntime) method before you use the script’s API members for the first time. This method forces the Resource Manager to load client resources:

// ...
@code {
    [Inject] IJSRuntime js;
    protected override async Task OnAfterRenderAsync(bool firstRender) {
        if(firstRender) {
            await js.LoadDxResources();
            await js.InvokeAsync("a-method-from-a-custom-script");
        }
        await base.OnAfterRenderAsync(firstRender);
    }
}

Inheritance

Object
DxResourceManager
See Also