1、aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TransferMoney.aspx.cs" Inherits="BtmsWebApp.report.TransferMoney" MasterPageFile="~/ReportPage.master" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
批量交易信息报表
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script>
function show() {
var s = document.getElementsByTagName("input");
var test = /^/d{4}-/d{2}-/d{2}$/;
for (var i = 0; i < s.length; i++) {
if ((s[i].name.indexOf("BEGINDATE") != -1) || (s[i].name.indexOf("ENDDATE") != -1)) {
if (!test.test(s[i].value)) {
alert("日期不能为空");
return false;
}
}
}
return true;
}
</script>
<table id="reportCondition">
<tr>
<td>
<table>
<tr>
<td>起始时间</td>
<td>
<asp:TextBox ID="txtDateFrom" runat="server" οnclick="new Calendar().show(this);"></asp:TextBox></td>
<td>截止时间:</td>
<td> <asp:TextBox ID="txtDateTo" runat="server" οnclick="new Calendar().show(this);"></asp:TextBox>
</td>
<td>商户号:</td>
<td> <asp:TextBox ID="txtMerchant" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="6"><asp:Button ID="btnSearch" runat="server" Text="查询"
οnclick="btnSearch_Click" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="ReportTD" valign="top">
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
SizeToReportContent="True" ProcessingMode="Remote" Width="100%" BackColor="#eaf6fc"
ShowFindControls="False" ToolTip="批量交易信息报表" ShowBackButton="true" ShowZoomControl="true"
AsyncRendering="False" ZoomMode="FullPage" ShowRefreshButton="true" Height="500px">
</rsweb:ReportViewer>
</td>
</tr>
</table>
</asp:Content>
2、cs
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSearch_Click(object sender, EventArgs e)
{
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = ReportViewer1.ServerReport;
// Set the report server URL and report path
string IpValue = ConfigurationManager.AppSettings["IpStr"].ToString();
serverReport.ReportServerUrl = new Uri("http://" + IpValue + "/reportserver");
serverReport.ReportPath = "/AhReports/TransferMoneyReport";
List<ReportParameter> paras = new List<ReportParameter>();
paras.Add(new ReportParameter("dateFrom", string.IsNullOrEmpty(txtDateFrom.Text.Trim()) ? string.Empty : txtDateFrom.Text.Trim()));
paras.Add(new ReportParameter("dateTo", string.IsNullOrEmpty(txtDateTo.Text.Trim()) ? string.Empty : txtDateTo.Text.Trim()));
paras.Add(new ReportParameter("merchantId", string.IsNullOrEmpty(txtMerchant.Text.Trim()) ? string.Empty : txtMerchant.Text.Trim()));
serverReport.SetParameters(paras);
}
3、母版页
<head id="Head" runat="server">
<title>
<asp:ContentPlaceHolder ID="TitleContent" runat="server" />
</title>
<script src="<%=VirtualPathUtility.ToAbsolute("~/Scripts/WebFormReportViewStyle.js") %>" type="text/javascript"></script>//去掉webForm 调用Reporting Service时,出现的两层滚动条
</head>
运行页面时,调整窗口适当大小,你最多会内外三层滚动条,如何去掉多余滚动条,参见调用 Reporting Service 时,怎么去掉滚动条