Skip to main content

ASPxWebDocumentViewer.OpenReport(String) Method

Opens the specified report in the ASPxWebDocumentViewer.

Namespace: DevExpress.XtraReports.Web

Assembly: DevExpress.XtraReports.v24.1.Web.WebForms.dll

NuGet Package: DevExpress.Web.Reporting

Declaration

public void OpenReport(
    string reportUrl
)

Parameters

Name Type Description
reportUrl String

A String value specifying a report unique name.

Remarks

You must implement a report name resolution service to convert the report name to a report instance when you use this method overload and pass a string that specifies the report name to the method.

If your application does not include the Report Designer component, implement and register the IReportProvider service.

The following code snippet is a sample implementation of the IReportProvider service that loads a report from a file located in the Reports folder:

using System.Web;
using DevExpress.XtraReports.Services;
using DevExpress.XtraReports.UI;
// ...
    public class CustomReportProvider : IReportProvider {
        public XtraReport GetReport(string id, ReportProviderContext context) {
            if (string.IsNullOrEmpty(id))
                return null;
            XtraReport report = new XtraReport();
            switch (id) {
                case "TestReport1":
                    report.LoadLayoutFromXml(HttpContext.Current.Server.MapPath("Reports//TestReport1.repx"));
                    return report;
            }
            return report;
        }
    }

Register the service on application startup before calling the StaticInitialize() method:

void Application_Start(object sender, EventArgs e) {
    // ...
    DevExpress.XtraReports.Web.WebDocumentViewer.DefaultWebDocumentViewerContainer.Register<IReportProvider, CustomReportProvider>();
    // ...
    ASPxReportDesigner.StaticInitialize();
    // ...
} 

If the application includes the Report Designer component, you must implement a descendant of ReportStorageWebExtension that works with both Document Viewer and Report Designer.

If both IReportProvider and ReportStorageWebExtension services are registered, the Document Viewer requests IReportProvider and the Report Designer requests ReportStorageWebExtension.

The following code snippets (auto-collected from DevExpress Examples) contain references to the OpenReport(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also