Skip to main content
All docs
.NET Framework 4.5.2+

How to: Access the Report Preview Control (Blazor)

This example demonstrates how to access the adapter of the DxDocumentViewer component that ASP.NET Core Blazor XAF applications use to display reports.

When a user previews a report, an ASP.NET Core Blazor application opens a Detail View that contains ReportViewerViewItem. Follow the steps below to access this View Item and its component:

  1. Add the DevExpress.ExpressApp.ReportsV2.Blazor NuGet package to the ASP.NET Core Blazor module project (MySolution.Module.Blazor). If your solution does not contain this project, add this package to the application project (MySolution.Blazor.Server).
  2. Create a View Controller. Set its View property to DetailView and TargetViewId to the View’s identifier. The ReportsBlazorModuleV2.ReportViewerDetailViewName constant stores this identifier.
  3. In the overridden OnActivated method, call the CustomizeViewItemControl<T>(DetailView, Controller, Action<T>) method.
  4. Use the ViewItem.Control property to access the Report Viewer’s control.

MySolution.Blazor.Server\Controllers\AccessReportViewerController.cs in solutions without the ASP.NET Core Blazor-specific module project. MySolution.Module.Blazor\Controllers\AccessReportViewerController.cs in solutions with the ASP.NET Core Blazor-specific module project.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.ReportsV2.Blazor;
// ...
public class AccessReportViewerController : ViewController<DetailView> {
    public AccessReportViewerController() {
        TargetViewId = ReportsBlazorModuleV2.ReportViewerDetailViewName;
    protected override void OnActivated() {
        View.CustomizeViewItemControl<ReportViewerViewItem>(this, CustomizeReportViewerViewItem);
    private void CustomizeReportViewerViewItem(ReportViewerViewItem reportViewerViewItem) {
        string reportName = ((ReportViewerViewItem.DxDocumentViewerAdapter)reportViewerViewItem.Control).ComponentModel.ReportName;
        // ...