2013-05-09 33 views
2

我想打开一个新的窗口,它同时包含面板打印为...如何打印(在新窗口)两个特定的面板ID

嗨,妳? 我很好.. !!

我使用这个脚本打印在头部

<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> 

通过这一点,我将只得到“嗨,ü?”打印,但我想“嗨,你好吗?我很好.. !!”.....

+0

不要ü想展示什么是有在面板上的一个新窗口? – 2013-05-09 11:55:05

+2

我认为你需要让你的问题更清晰。 – 2013-05-09 11:56:12

+0

@MicrosoftPS:是的。但也必须做它的纸张印刷...... – 2013-05-09 11:57:09

回答

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();"> 
+0

@MiteshJain,请参阅我的编辑。 – 2013-05-09 12:40:13

+0

其实我身上有很多东西,但我不想打印所有的身体内容,只需要打印2个面板。我该怎么办?????? – 2013-06-19 18:27:41

相关问题