The WebViewer control that is licensed with the Professional Edition allows you to quickly display reports in Web applications.
Once you drop the control onto a Web Form, you can look in the Visual Studio Properties grid and select the ViewerType that you want to use.
The WebViewer control supports the following types:
- HtmlViewer (default): Provides a scrollable view of a single page of the report at a time. Downloads only HTML and javascript to the client browser. Not recommended for printable output. See the HTML Viewer topic for details.
- RawHTML: Shows all pages in the report document as one continuous HTML page. Provides a static view of the entire report document, and generally printable output, although under some circumstances pagination is not preserved.
- AcrobatReader: Returns output as a PDF document viewable in Acrobat Reader.
Client requirements: Adobe Acrobat Reader - FlashViewer: Provides an interactive viewing experience and no-touch printing using the widely-adopted Flash Player. See Using the Flash Viewer for details.
Client requirements: Adobe Flash Player
To use the WebViewer control
- In a Visual Studio Web Application, add the WebViewer control to the Visual Studio toolbox. See Adding ActiveReports Controls for more information.
- While in Design view of an ASPX page, from the toolbox, drag the WebViewer control and drop it on the page.
- With the WebViewer control selected, in the Properties grid, select the ViewerType you want to use. The viewer displays any prerequisites for using the selected ViewerType.
- To bind a report to the WebViewer, do one of the following:
- Set the ReportName property to the name of a report within your solution.
Note: Alternatively, you can set the ReportName property programmatically to a new instance of an ActiveReport class. For example:
VB code: WebViewer.ReportName="YourReport.rpx"
C# code: WebViewer.ReportName="YourReport.rpx";
- Set the Report property to a new instance of an ActiveReport class as shown in the examples below.
To write the code in Visual Basic.NET (Page report)
VB code. Paste INSIDE the Page Load event Copy Code Dim rpt As New GrapeCity.ActiveReports.PageReport() rpt.Load(New System.IO.FileInfo(Server.MapPath("")+"\invoice.rdlx")) WebViewer1.Report = rpt
To write the code in C# (Page report)
C# code. Paste INSIDE the Page Load event Copy Code GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport(); rpt.Load(new System.IO.FileInfo(Server.MapPath("")+"\\invoice.rdlx")); WebViewer1.Report = rpt;
To write the code in Visual Basic.NET (Section code-based report)
VB code. Paste INSIDE the Page Load event Copy Code Dim rpt As New MyInvoiceReport() WebViewer1.Report = rpt
To write the code in C# (Section code-based report)
C# code. Paste INSIDE the Page Load event Copy Code MyInvoiceReport rpt = new MyInvoiceReport(); WebViewer1.Report = rpt;
To write the code in Visual Basic.NET (Section xml-based report)
VB code. Paste INSIDE the Page Load event Copy Code Dim sr As New SectionReport() sr.LoadLayout(Server.MapPath("") + "\Invoice.RPX") WebViewer1.Report = sr
To write the code in C# (Section xml-based report)
C# code. Paste INSIDE the Page Load event Copy Code SectionReport sr = new SectionReport(); sr.LoadLayout(Server.MapPath("") + "\\Invoice.RPX); WebViewer1.Report = sr;
Note: You can use either the ReportName property or the Report property to bind a report to the WebViewer. If you use both properties, you will get the error message.
- Set the ReportName property to the name of a report within your solution.
- You must also Configure HTTPHandlers in IIS 6.x on your server so that IIS knows how to associate ActiveReports files in the browser.