Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.i can't print a web page.i want create a button in web page and when i click it,print page.????????????
Posted

use this script
1)
XML
<script language="javascript" type="text/javascript">
                function CallPrint(strid) {
                    var prtContent = document.getElementById(strid);
                    var WinPrint = window.open('', '', 'letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
                    WinPrint.document.write(prtContent.innerHTML);
                    WinPrint.document.close();
                    WinPrint.focus();
                    WinPrint.print();
                    WinPrint.close();
                    prtContent.innerHTML = strOldOne;
                }
</script>


2)
HTML
<div id="bill"></div>

//the content will be printed .
3)
XML
<asp:button id="BtnPrint" runat="server" text="Print" onclientclick="javascript:CallPrint('bill');" xmlns:asp="#unknown" />
</div>
 
Share this answer
 
You can use window.print() (JavaScript) to print a webpage on a button click.
 
Share this answer
 
check out the link for explanation

http://www.javascriptkit.com/howto/newtech2.shtml[^]
 
Share this answer
 
Link on codeproject [^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900