程序调用过程:
1 report调用
Server.Transfer("~/R0000/ReportViewer.aspx",false);
2 reportviewer.aspx
-------------------------------------------
<%@ Page Language="C#" MasterPageFile="~/VivaBase.master" AutoEventWireup="true" Inherits="R0000_ReportViewer" Title="ReportViewer" Codebehind="ReportViewer.aspx.cs" %>
<%@ Register TagPrefix="activereportsweb" Namespace="DataDynamics.ActiveReports.Web"
Assembly="ActiveReports.Web, Version=6.0.2019.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" %>
<%@ PreviousPageType VirtualPath="~/R0000/R1001.aspx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<table style="width:100%;height:100%">
<tr>
<td align="left">
<aspabel ID="lblViewerType" runat="server" Font-Bold="True" >Select Viewer Type:</aspabel>&nbsp;
<aspropDownList ID="cboViewerType" runat="server" Width="150px">
</aspropDownList>
<asp:Button ID="BtnView" runat="server" OnClick="BtnView_Click" Text="View" Width="65px" />
</td>
</tr>
<tr style="width:100%;height:95%">
<td align="center" >
<activereportsweb:WebViewer ID="arvWebMain" runat="server" Width="100%" Height="650px">
<dfExportOptions
Application="GrapeCity ActiveReports (tm) 6">
</PdfExportOptions>
<FlashViewerOptions ShowSplitter="False" ShowToc="False">
</FlashViewerOptions>
</activereportsweb:WebViewer>
</td>
</tr>
</table>
</asp:Content>
----------------------------------
reportviewer.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataDynamics.ActiveReports;
public partial class R0000_ReportViewer : System.Web.UI.Page
{
public string rptName = string.Empty;
protected void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
// if this is not the postback, then fill the dropdown/combo with it's available viwer types.
if (!this.IsPostBack)
{
// it's not a postback, so populate that combo
this.cboViewerType.Items.Clear();
this.cboViewerType.Items.Add("HtmlViewer");
this.cboViewerType.Items.Add("DF Reader");
this.cboViewerType.Items.Add("MS Excel");
//this.cboViewerType.Items.Add("FlashViewer");
//this.cboViewerType.Items.Add("RawHtml");
this.cboViewerType.SelectedIndex = 0;// the default is HTML.
if (Page.PreviousPage != null) {
string RptType = PreviousPage.RptType;
switch (RptType)
{
case "0801":
arvWebMain.ReportName = "Rpt01.rpx";
break;
case "0802":
arvWebMain.ReportName = "Rpt02.rpx";
break;
case "0803":
arvWebMain.ReportName = "Rpt03.rpx";
break;
case "0804":
arvWebMain.ReportName = "Rpt04.rpx";
break;
case "0805":
arvWebMain.ReportName = "Rpt05.rpx";
break;
case "0806":
arvWebMain.ReportName = "Rpt06.rpx";
break;
}
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
/// <summary>
/// commit_Click - runs with the user click the view button
/// and selects a different viewing mode.
/// </summary>
protected void BtnView_Click(object sender, EventArgs e)
{
// Set the Viewer Type from the dropdown list to the ActiveReports WebViewer
string selection = this.cboViewerType.Items[this.cboViewerType.SelectedIndex].Text;
switch (selection)
{
case "DF Reader": //Acrobat Reader was chosen as the viewer type
this.arvWebMain.ViewerType = DataDynamics.ActiveReports.Web.ViewerType.AcrobatReader;
break;
//case "FlashViewer": //Flash was chosen as the viewer type
// this.arvWebMain.ViewerType = DataDynamics.ActiveReports.Web.ViewerType.FlashViewer;
// break;
case "HtmlViewer": //HTML Viewer was chosen as the viewer type
this.arvWebMain.ViewerType = DataDynamics.ActiveReports.Web.ViewerType.HtmlViewer;
break;
case "RawHtml": //Raw HTML was chosen as the viewer type
this.arvWebMain.ViewerType = DataDynamics.ActiveReports.Web.ViewerType.RawHtml;
break;
case "MS Excel":
break;
}
}
} |