|
While migrating my code to Visual Studio .Net 2005, I ran into problems getting ActiveReports viewer to work in my ASP pages. What I wanted to accomplish seemed pretty simple: I had a page that collected some report criteria (select and sort stuff), then filled a typed Dataset, then passed it to an ActiveReports report, then display it in a viewer page. The documentation was no help. Neither was the sample code. The sample code showed some interesting but non-applicable-to-me ways of saving reports to a directory and then viewing the stored report in the directory, or spitting reports out on-the-fly in some raw format. There's some intriguing stuff there, but where's a simple sample? In the end I was able to do it pretty much the same way I had done in .Net 2003 (using ActiveReports 3.3.1.2009). There are 4 steps: 1. Create an aspx page that has the viewer. This can be as simple as this: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReportViewer.aspx.cs" Inherits="ReportViewer" Title="ReportViewer" %> <%@ Register Assembly="ActiveReports.Web, Version=4.2.0.1186, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" Namespace="DataDynamics.ActiveReports.Web" TagPrefix="ActiveReportsWeb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" http://www.w3.org/1999/xhtml"> <head runat="server"> <title>ReportViewer</title> </head> <body> <ActiveReportsWeb:WebViewer ID="WebViewer1" runat="server" Height="600" Width="900" /> </body> </html> The only thing different from the past was the version number. 2. In the code-behind, load up the ActiveReport and stick it in the viewer. Again, this code is pretty simple: using (the default stuff) using DataDynamics.ActiveReports; public partial class ReportViewer : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { ActiveReport myReport = (ActiveReport)Session.Contents["ReportObject"]; myReport.Run(); WebViewer1.Report = myReport; WebViewer1.ViewerType = DataDynamics.ActiveReports.Web.ViewerType.ActiveXViewer; } } 3. In the web.config file, add the httpHandlers info in the system.web section like this: <httpHandlers> <add verb="*" path="*.rpx" type="DataDynamics.ActiveReports.Web.Handlers.RpxHandler, ActiveReports.Web, Version=4.2.0.1186, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> <add verb="*" path="*.ActiveReport" type="DataDynamics.ActiveReports.Web.Handlers.CompiledReportHandler, ActiveReports.Web, Version=4.2.0.1186, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> <add verb="*" path="*.ArCacheItem" type="DataDynamics.ActiveReports.Web.Handlers.WebCacheAccessHandler, ActiveReports.Web, Version=4.2.0.1186, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> </httpHandlers> 4. In IIS, in the properties site, in the Home Directory tab in the Configuration button, entries for ActiveReport, ArCacheItem, and rpx. There is a KB article that talks about this at http://www.datadynamics.com/ShowPost.aspx?PostID=574. And that's that. So here's my comment: It should not have been so difficult to figure this all out. I had to do a bunch of digging to find the information. There is no mention of the <ActiveReportsWeb:WebViewer> tag approach anywhere in the "ActiveReports for .NET 2.0" documentation or samples. There is no mention of the entries in the web.config file or the IIS ISAPI extensions stuff -- or mention that if you don't do this you get a "Error 5013: Invalid DataPath. Cannot Load Data" error. This error message does not give any hint of 'oh, I forgot to update my web.config and IIS'. Just my two cents. I like ActiveReports -- it's great. Keep up the good work.
|