ASP.NET Web Sample | Samples | Walkthroughs | ActiveX Viewer Control

See Also ActiveReports for .NET Web Help Send feedback to Data Dynamics

Walkthrough: Using ActiveX Viewer Control on the Web

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 (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 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

  1. Open a new ASP.NET Web application in Visual Studio.
  2. Click on Project > Add New Item.
  3. Select ActiveReports file and rename the file rptActiveX.
  4. Click Open.

Connecting the report to a data source

To connect the report to a data source

 

  1. Click on the yellow report DataSource icon in the Detail section. This brings up the report DataSource dialog box.
  2. Click on Build...
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next >>.
  4. Click on the ellipsis to browse for the access path to NWind.mdb. 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.
  2. Make the following changes to the group header:
    • Change the name to ghCategories
    • Change the DataField property to CategoryID
  3. Add the following controls to the GroupHeader section:

     

    Control Name Text/Caption Location
    Label lblProductName Product Name 0, 0
    Label lblUnitsInStock Units In Stock 1.875, 0
    Label lblUnitsOnOrder Units On Order 2.9375, 0
    Label lblUnitPrice Unit Price 4, 0

     

  4. Add the following controls to the Detail section:

     

    Control DataField Name Text/Caption Location Output Format
    TextBox ProductName txtProductName Product Name 0, 0 (Empty string)
    TextBox UnitsInStock txtUnitsInStock Units In Stock 1.875, 0 (Empty string)
    TextBox UnitsOnOrder txtUnitsOnOrder Units On Order 2.9375, 0 (Empty string)
     
    TextBox UnitPrice txtUnitPrice 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 is installed.
  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

In the body of the HTML view of the Web Form, but outside the <form> tags, add the following code:

<OBJECT id="arv" codeBase="arview2.cab" height="100%" width="100%"
classid="clsid:8569D715-FF88-44BA-8D1D-AD3E59543DDE" VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="11218">
<PARAM NAME="_ExtentY" VALUE="7329"></OBJECT>

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

To write the code in 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", _
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", _
RdfFormat.AR20);
}

ASP.NET Web Sample | Samples | Walkthroughs | ActiveX Viewer Control

 

 


Copyright © 2005 Data Dynamics, Ltd. All rights reserved.