Monday, October 17, 2011

Print DIV

If you want to Print your aspx page. you can create DIV and call the DIV in print.


<div id="passedindata" >

<table width="755" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>Test </td>
<td>Test 2</td>
</tr>
</table>

<div/>

<img onclick="CallPrint('divPrint');" alt="" src="images\btn_print.png" />


<script language=javascript>
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint =
window.open('','','left=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
//prtContent.innerHTML=strOldOne;
}
</script>

No comments:

Post a Comment