Glossary Item Box

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

Tasks: Visual Studio.NET 2005 Web Changes

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

Walkthrough: Using the 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.

Note: Before performing this walkthrough, you must first run "Configure Web Sample" (Start menu > All Programs > Data Dynamics > ActiveReports for .NET 2.0 > Samples > VB or CSharp) or manually configure Internet Information Services.

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

Important: If you are using Visual Studio.NET 2005, please see the Visual Studio.NET 2005 Web Changes topic.

To add an ActiveReport to your project

  1. Open a new ASP.NET Web application in Visual Studio.
  2. From the Project (or Website) menu, select 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 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 2, 0
    Label lblUnitsOnOrder Units on Order 3, 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 2, 0 (Empty string)
    TextBox UnitsOnOrder txtUnitsOnOrder Units on Order 3, 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 2.0 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. Right-click the ReportOutput folder, select Sharing and Security..., and give write permissions for this folder to the Users group.

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 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.
    var arv = document.getElementById("arv");
    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", _
	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);
}

Also in design view, resize arv to

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

Tasks: Visual Studio.NET 2005 Web Changes

 

 


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