我的页面中有3个网格视图。我正在使用javascript将它们全部打印出来。
现在,我想将每个网格视图打印到单独的页面中。
下面是我的JavaScript代码。
<script type = "text/javascript">
function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title></title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>发布于 2016-08-30 20:07:14
我使用CSS为我做这件事: css:
.pageBreak {
position: relative;
page-break-after: always
}html:
<div id="gridView1" class="pageBreak">
<!-- your grid view -->
</div>在您的情况下,它可能是这样的:
<script type = "text/javascript">
function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID %>");
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title></title>');
printWindow.document.write('</head><body>');
printWindow.document.write('<div class="pagereak"');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</div></body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>虽然在您的例子中,pageBreak类应该在innerHTML中,但我猜
https://stackoverflow.com/questions/39226984
复制相似问题