打印web控件例如:Button, GridView,TextBox, RadGridView....
1 <script type="text/javascript">
2 function doPrint() {
3 var prtContent = document.getElementById('<%= Button1.ClientID %>');
4 prtContent.border = 0; // set no border here
5 var WinPrint = window.open('', '', 'left=100,top=100,width=1000,height=1000,toolbar=0,scrollbars=1,status=0,resizable=1');
6 WinPrint.document.write(prtContent.outerHTML);
7 WinPrint.document.close();
8 WinPrint.focus();
9 WinPrint.print();
10 WinPrint.close();
11 }
12 </script>
2 function doPrint() {
3 var prtContent = document.getElementById('<%= Button1.ClientID %>');
4 prtContent.border = 0; // set no border here
5 var WinPrint = window.open('', '', 'left=100,top=100,width=1000,height=1000,toolbar=0,scrollbars=1,status=0,resizable=1');
6 WinPrint.document.write(prtContent.outerHTML);
7 WinPrint.document.close();
8 WinPrint.focus();
9 WinPrint.print();
10 WinPrint.close();
11 }
12 </script>
调用方法:
1 <asp:Button ID="Button1" runat="server" OnClientClick="doPrint()"
2 Text="Button" />
2 Text="Button" />