You can use the ReportList control to retrieve a list of available reports from ActiveReports Server. You can also use it to let your users export reports to PDF, Word, or Excel format. Here is how to retrieve reports from the server by entering credentials in the log-in screen or through the Web.config file.
Controls for the Log In page
Control | Text Property |
---|---|
Label | User Name: |
TextBox | ? |
Label | Password: |
TextBox | ? |
Button | Log In |
Visual Basic
Visual Basic (Paste INSIDE SessionStorage.vb) |
Copy Code
|
---|---|
Imports System Imports System.Web Namespace App_Code Public Class SessionStorage Private Const SecurityTokenKey As String = "{DEBDB016-040A-48f4-B568-897E6D410919}" Public Shared Property SecurityToken() As String Get Return TryCast(HttpContext.Current.Session(SecurityTokenKey), String) End Get Set(value As String) HttpContext.Current.Session(SecurityTokenKey) = value End Set End Property End Class End Namespace |
C#
C# (Paste INSIDE SessionStorage.cs) |
Copy Code
|
---|---|
using System; using System.Web; namespace App_Code { public static class SessionStorage { private const string SecurityTokenKey = "{DEBDB016-040A-48f4-B568-897E6D410919}"; public static string SecurityToken { get { return HttpContext.Current.Session[SecurityTokenKey] as string; } set { HttpContext.Current.Session[SecurityTokenKey] = value; } } } } |
Visual Basic
Visual Basic (Paste at the top of file) |
Copy Code
|
---|---|
Imports ActiveReports.Server.ReportControls.Servicing Imports App_Code |
C#
C# (Paste at the top of file) |
Copy Code
|
---|---|
using ActiveReports.Server.ReportControls.Servicing; using App_Code; |
Note: An error occurs on the following line until you add the ActiveReports.Server.ReportControls.dll reference using the steps mentioned in To add the ReportList control to a Web Form.
using ActiveReports.Server.ReportControls.Servicing;
Visual Basic
Visual Basic (Paste INSIDE the button click event) |
Copy Code
|
---|---|
Dim username = TextBox1.Text Dim password = TextBox2.Text Dim reportService = New ReportServiceProxy() SessionStorage.SecurityToken = Nothing Dim securityToken = reportService.Login(username, password, Nothing, False) SessionStorage.SecurityToken = securityToken Server.Transfer("Default2.aspx") |
C#
C# (Paste INSIDE the button click event) |
Copy Code
|
---|---|
var username = TextBox1.Text; var password = TextBox2.Text; var reportService = new ReportServiceProxy(); SessionStorage.SecurityToken = null; var securityToken = reportService.Login(username, password, null, false); SessionStorage.SecurityToken = securityToken; Server.Transfer("Default2.aspx"); |
Note: An error occurs on the following line until you add the ActiveReports.Server.ReportControls.dll reference using the steps mentioned in To add the ReportList control to a Web Form.
Dim reportService = New ReportServiceProxy()
OR
var reportService = new ReportServiceProxy();
To enable the ASP.NET compatibility mode
ASP.NET code. Paste BETWEEN the <configSections> tab and </configSections> |
Copy Code
|
---|---|
<system.serviceModel> |
Note: These steps are required when using an ASP.NET website. You do not need to create the .svc file manually in an ASP.NET Web application, as it automatically adds a service file when you drop a ReportList control on the web form.
To create .svc file for WCF service
ASP.NET code |
Copy Code
|
---|---|
<%@ ServiceHost Service="ActiveReports.Server.ReportControls.Servicing.ReportServiceProxy" Factory="ActiveReports.Server.ReportControls.Servicing.ReportServiceHostFactory" %> |
If you need to add the control to your toolbox, drop down these steps.
Note: The .svc file is not added automatically in an ASP.NET Website. You need to manually add the ReportService.svc file using the steps in To create an .svc file for the WCF service.
Note: The ReportServicePath property is not automatically set in an ASP.NET website. You need to manually set the file path of ReportService.svc.
You can specify the security token and ActiveReports 12 Server host using code in a Global Application Class.
To import the Servicing namespace
ASP.NET code. (Paste on the line BELOW the Application Language line) |
Copy Code
|
---|---|
<%@ Import Namespace="ActiveReports.Server.ReportControls.Servicing" %> <%@ Import Namespace="App_Code" %> |
Visual Basic (Paste at the top of Global.asax.vb file) |
Copy Code
|
---|---|
Imports ActiveReports.Server.ReportControls.Servicing Imports App_Code |
C# (Paste at the top of Global.asax.cs file) |
Copy Code
|
---|---|
using ActiveReports.Server.ReportControls.Servicing; using App_Code; |
Visual Basic
Visual Basic (Paste in the Global.asax file AFTER the Application_Start event) |
Copy Code
|
---|---|
Private Shared Sub ResolveRemoteEndpoint(remoteEndpoint As RemoteEndpoint) remoteEndpoint.Address = "http://localhost:8080" remoteEndpoint.SecurityToken = SessionStorage.SecurityToken End Sub |
C#
C# (Paste in the Global.asax file AFTER the Application_Start event) |
Copy Code
|
---|---|
static void ResolveRemoteEndpoint(RemoteEndpoint remoteEndpoint) { remoteEndpoint.Address = "http://localhost:8080"; remoteEndpoint.SecurityToken = SessionStorage.SecurityToken; } |
To provide a handler for the event
C# code. Paste INSIDE the Application_Start event. |
Copy Code
|
---|---|
ReportServiceProxy.ResolveRemoteEndpoint += ResolveRemoteEndpoint; |
You can also specify the user name, password, and ActiveReports 12 Server host in your web application's web.config file.
In the web.config file, add credentials using code like the following.
ASP.NET code. Paste in the web.config file AFTER the </configSections> tag. |
Copy Code
|
---|---|
<configSections> <sectionGroup name="activereports.server"> <section name="reportServiceProxy" type="ActiveReports.Server.ReportControls.Configuration.ActiveReportsServerSection, ActiveReports.Server.ReportControls, Version=12.x.xxxx.0, Culture=neutral, PublicKeyToken=d557f2f30a260da2" allowDefinition="Everywhere" /> </sectionGroup> </configSections> <activereports.server> |
At run time, the ReportList control retrieves all of the reports from ActiveReports 12 Server, and provides buttons to export each to PDF, Word, and Excel.