2

我想打开一个新窗口,它包含两个面板打印...

嗨!你好吗?我没事..!!

我使用此脚本在 Head 部分进行打印

<head> 
<scripttype="text/javascript">
functionPrintPanel() {
var panel = document.getElementById("<%=Pa1.ClientID%>");

varprintWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>DIV Contents</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
         }, 500);
returnfalse;
     }
</script>
</head>

在身体部分我有

<body>
<asp:ImageButtonID="print_btn"runat="server"
ImageUrl="~/images/awards2.jpg"OnClientClick="return 
PrintPanel();"Height="50"Width="50"/>

<asp:Panel ID="Pa1" runat="server">Hi, How are u?</asp:Panel>
<asp:Panel ID="Pa2" runat="server">I am fine..!!</asp:Panel>
</body>

通过这个,我只会得到“嗨,你好吗?” 打印,但我想要“嗨,你好吗?我很好..!!”.....

4

1 回答 1

2

因为这些是作为 DIV 呈现的,所以您需要在它们之间放置一个中断。所以它看起来像这样:

<asp:Panel ID="Pa1" runat="server">Hi, How are u?</asp:Panel>
<br />
<asp:Panel ID="Pa2" runat="server">I am fine..!!</asp:Panel>

要在加载页面时打印页面,请执行以下操作:

<body onload="javascript:windows.print();">
于 2013-05-09T11:57:15.020 回答