ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Using the ActiveX Viewer Control on the Web
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Web Walkthroughs (Standard Edition) > Walkthrough: Using the ActiveX Viewer Control on the Web

Glossary Item Box

The ActiveX Viewer Control allows you to view and print report output in a web browser.

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 rptActiveX.
  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 rptActiveX.
  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 on the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Click on Build.
  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".
  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 rptActiveX 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 property to ghCategories
    • Change the BackColor property to RosyBrown
    • Change the DataField property to CategoryID
  3. Add labels with the following properties to ghCategories:

    Name Text Location
    lblProductName Product Name 0, 0
    lblUnitsInStock Units In Stock 1.88, 0
    lblUnitsOnOrder Units On Order 2.94, 0
    lblUnitPrice Unit Price 4, 0

  4. Set the CanShrink property of the detail section to True.
  5. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the following properties of each textbox as indicated.

    Field Text Location Output Format
    ProductName Product Name 0, 0 NA
    UnitsInStock Units In Stock 1.88, 0 NA
    UnitsOnOrder Units On Order 2.94, 0 NA 
    UnitPrice Unit Price 4, 0 Currency

Adding the ActiveX .cab file to the project folder

To add the ActiveX .cab file

  1. Open Windows Explorer and browse to the folder in which ActiveReports for .NET 3.0 is installed. The default location is "C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0."
  2. Double-click the Deployment folder. Copy the file called "arview2.cab" by right-clicking on the file and selecting Copy.
  3. Browse to the folder in which your project is contained.
  4. Paste the .cab file into your project's folder.

Adding a ReportOutput folder to the project folder

To add a folder to the project

  1. Open Windows Explorer and browse to the folder in which your project is contained.
  2. On the File menu, click New> Folder.
  3. Name the folder "ReportOutput".
  4. Make sure that you have write permissions for this folder.

Adding Object tags to the Web Form's HTML code

To add Object tags to the Web Form

Adding code to the Web Form's window_onload event

To add code to the window_onload event

  1. At the top of the HTML view of the Web Form, click on the drop-down arrow for "Client Objects and Events" and select "window".
  2. Click the drop-down arrow for the available events to the right of "window" and select "onload."
  3. This creates an event-handling method for the Web Form's window_onload event.
  4. Add the following code to the window_onload event.
    arv.datapath = "ReportOutput/axreport.rdf";

Adding code to the Web Form's Page_Load event

To write the code in Visual Basic or C#

The following example shows what the code for the method looks like.

'Visual Basic
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _ MyBase.Load
Dim rpt As New rptActiveX()
rpt.Run()
rpt.Document.Save(Server.MapPath("") + "\ReportOutput\axreport.rdf", DataDynamics.ActiveReports.Document.RdfFormat.AR20)
End Sub
//C#
private void Page_Load(object sender, System.EventArgs e)
{
rptActiveX rpt = new rptActiveX();
rpt.Run();
rpt.Document.Save(Server.MapPath("") + "\\ReportOutput\\axreport.rdf", DataDynamics.ActiveReports.Document.RdfFormat.AR20);
}

See Also

©2009. All Rights Reserved.