IWebDocumentViewerReportResolver Interface

If implemented by a class, resolves reports that can be displayed by the Web Document Viewer control by their type names.

Namespace: DevExpress.XtraReports.Web.WebDocumentViewer

Assembly: DevExpress.XtraReports.v18.1.Web.dll

Syntax

public interface IWebDocumentViewerReportResolver

The default report resolver tries to load a report based on its fully qualified type name. To provide a custom report resolver, create a class implementing the IWebDocumentViewerReportResolver interface.

Below is a sample implementation of the IWebDocumentViewerReportResolver interface that allows a web application to resolve reports based on predefined custom identifiers in addition to the default behavior.

using DevExpress.XtraReports.Web.WebDocumentViewer;
using DevExpress.XtraReports.UI;
// ...

public class CustomWebDocumentViewerReportResolver : IWebDocumentViewerReportResolver {
    public CustomWebDocumentViewerReportResolver() { }

    public XtraReport Resolve(string reportTypeName) {
        switch (reportTypeName) {
            case "Report1":
                return new XtraReport1();
            case "Report2":
                return new XtraReport2();
            default:
                // Try to create a report using the fully qualified type name.
                Type t = Type.GetType(reportTypeName);
                return typeof(XtraReport).IsAssignableFrom(t) ?
                    (XtraReport)Activator.CreateInstance(t) :                
                    null;                                             
        }      
    }
}

Register your custom report resolver in the application's Global.asax file. For example:

void Application_Start(object sender, EventArgs e) {
    DefaultWebDocumentViewerContainer.Register<IWebDocumentViewerReportResolver, CustomWebDocumentViewerReportResolver >();
}

Next, to avoid updating the entire web page when previewing a new report document, call the ASPxWebDocumentViewer.OpenReport method with the specified report ID.

See Also