Web 打印

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

调用方法:

 

1 <asp:Button ID="Button1" runat="server" OnClientClick="doPrint()"
2             Text="Button" />

 

posted @ 2011-10-18 16:22  丁守庆  阅读(243)  评论(0编辑  收藏  举报
专业成就价值