ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: HTTP Handlers
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Professional Edition Walkthroughs > Walkthrough: HTTP Handlers

Glossary Item Box

ActiveReports provides HTTPHandler components that, upon configuration, allow ASP.NET to automatically process reports that have been placed into an ASP.NET web site folder. ActiveReports HTTPHandler components enable reports to be easily deployed in both HTML and PDF. ActiveReports includes a simple configuration utility to properly register the HTTPHandler components with IIS and ASP.NET.

This walkthrough illustrates how to create a simple Web application and set the HTTPHandler to output report information in PDF format.

This walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data\NWIND.MDB. You must also have access to Internet Information Services either from your computer or from the server. You must also run the "Configure Web Sample" option from the Data Dynamics ActiveReports for .NET 3.0 program menu from your Windows Start button.

When you have completed this walkthrough, you will have a report that looks similar to the following.

Adding an ActiveReport to an ASP.NET Web application

To add an ActiveReport to your project using Visual Studio 2003

  1. Create a new ASP.NET Web application. 
  2. From the Project menu, select Add New Item
  3. Select ActiveReports 3.0 File and rename the file rptHttpHandlers.
  4. Click Open.

To add an ActiveReport to your project using Visual Studio 2005

  1. Create a new ASP.NET Web site. 
  2. From the Website menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptHttpHandlers.
  4. Click Add.
  5. Click Yes when a message box asks whether you would like to place the class in the 'App_Code' folder.

Connecting the report to a data source

To connect the report to a data source

  1. Click the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Click the Build button.
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next.
  4. Click the ellipsis button to browse for the access path to the Northwind database. Click Open once you have selected the appropriate access path.
  5. Click OK to continue.
  6. In the Query field, type "Select * from products ORDER BY categoryID, productname".
  7. Click OK to return to the report design surface.

Adding controls to the report to contain data

To add controls to the report

  1. Add a GroupHeader/Footer section to rptHTTPHandlers by right-clicking the design surface of the report and selecting Insert > Group Header/Footer.
  2. Make the following changes to the group header:
    • Change the name to ghProducts
    • Change the DataField property to CategoryID
    • Change the GroupKeepTogether property to FirstDetail
    • Change the KeepTogether property to True
  3. Add labels to ghProducts, setting the properties as indicated in the table below:

    Name Text Location
    lblProductName Product Name 0, 0
    lblQuantityPerUnit Quantity Per Unit 1.19, 0
    lblInStock In Stock 2.5, 0
    lblUnitPrice Unit Price 4, 0

  4. Drag the following fields from the Report Explorer onto the detail section, setting the properties as indicated in the table below. 

    Field Text Location OutputFormat
    ProductName Product Name 0, 0 NA
    QuantityPerUnit Quantity Per Unit 1.19, 0 NA
    UnitsInStock Units In Stock 2.5, 0 NA 
    UnitPrice Unit Price 4, 0 Currency
  5. Change the CanShrink property of the detail section to True.

Saving the report layout to rpx format

To save the report layout to rpx format

  1. From the Report menu, select Save Layout.
  2. Navigate to the project's main folder, name the file rptHTTPHandlers and save it as type Arnet3 Format (*rpx).

Adding code to the Web.config file to enable HTTPHandler

To add code to the Web.config file

  1. Double-click the Web.config file in the Solution Explorer window.
  2. In the XML view, add the following code immediately before the closing system.web tag near the bottom of the page.
        <httpHandlers>
        	<!--
        	********** ActiveReports HttpHandler Configuration **********
        	-->
        	<add verb="*" path="*.rpx" type="DataDynamics.ActiveReports.Web.Handlers.RpxHandler, ActiveReports.Web,
        	Version=5.0.0.101, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
        	<add verb="*" path="*.ActiveReport" type="DataDynamics.ActiveReports.Web.Handlers.CompiledReportHandler,
        	ActiveReports.Web, Version=5.0.0.101, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
        	<add verb="*" path="*.ArCacheItem" type="DataDynamics.ActiveReports.Web.Handlers.WebCacheAccessHandler,
        	ActiveReports.Web, Version=5.0.0.101, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
        </httpHandlers>	
  3. Remove line breaks from the verbs if you copy and paste them so that each of the three is completed on a single line.
The version number must be updated to reflect the information for the current version of ActiveReports installed on your computer.

Adding a link to the Web Form

To add a link to the Web Form and enable viewing in PDF format

  1. In the HTML view of the Web Form (.aspx), add the following HTML code.
    <a href="rptHTTPHandlers.rpx?OutputFormat=pdf">WebApp.rpx/OutputFormat=pdf</a>	
  2. Press F5 to run the program.
  3. Click the link on the web form to convert the report preview to PDF.

See Also

©2009. All Rights Reserved.