VS2012 ReportViewer 自适应大小
思路:
用 DIV 包住 ReportViewer 控件,设置此控件高度和宽度为 100% ,然后在窗体 加载和改变尺
寸时,用 js 代码调整 DIV 的尺寸。
以下是代码内容:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>打印预览</title>
<script type="text/javascript" src="../client-scripts/jquery-1.7.2.js"></script>
<script language="javascript" type="text/javascript">
function bodyresize() {
var o_r = document.getElementById("content1");
o_r.style.width = (document.body.clientWidth).toString() + "px";
o_r.style.height = (document.documentElement.clientHeight-10).toString() +
"px";
}
</script>
</head>
<body scroll="no" style="overflow:hidden" onload="bodyresize();"
onresize="bodyresize();">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="content1">
<rsweb:ReportViewer ID="rvReporting" runat="server"
ShowDocumentMapButton="False" ShowExportControls="False"
ShowFindControls="False" ShowPromptAreaButton="False"
ShowZoomControl="False" BackColor="White" ShowPrintButton="false"
Height="100%" Width="100%">
</rsweb:ReportViewer>
</div>
</form>
</body>
</html>
评论6