2013-05-09 106 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

相關問題