Asp.Net Print WebPage From Javascript

To make Print Of Asp.Net Page Use following Javascript.

And Pass Div’s id to ptinrt Particular Portion Of Page.

<script language=”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>

Call Above Javascript On button Like

<asp:Button ID=”Button1″ runat=”server” OnClientClick=”javascript:CallPrint(‘Report’);” Text=”Print Preview” />

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s