ASP.NET 線上列印寫法~在網上看到的,怕忘記所以記上來。

線上列印

01
02     <script language="javascript" type="text/javascript">
03 // <!CDATA[
04
05 function

printform()
06 {
07     var printContent = document.getElementById("<%= pnlPrint.ClientID %>");
08     var windowUrl = 'about:blank';
09     var uniqueName = new Date();
10     var windowName = 'Print' + uniqueName.getTime();
11     var printWindow = window.open(windowUrl, windowName);
12
13     printWindow.document.write(printContent.innerHTML);
14     printWindow.document.close();
15     printWindow.focus();            
16     printWindow.print();
17     printWindow.close();
18 }
19         
20 function Button1_onclick()
21 {
22     printform();
23 }
24 // ]]>
25     </script>
26
27     <input id="btnPrint" runat="server" onclick="return Button1_onclick()" type="button"
28         value="列印" />