Tuesday 1 January 2013

print one part in form asp.net


No print preview, but this will print only the specified <div> tag:

<form id="Form1" method="post" runat="server">
 <div id="Div1">
  Printable content
 </div>
 <input type="button" value="Print" onclick="JavaScript:printPartOfPage('Div1');">

<script type="text/javascript">
<!--
function printPartOfPage(elementId)
{
 var printContent = document.getElementById(elementId);
 var windowUrl = 'about:blank';
 var uniqueName = new Date();
 var windowName = 'Print' + uniqueName.getTime();
 var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');

 printWindow.document.write(printContent.innerHTML);
 printWindow.document.close();
 printWindow.focus();
 printWindow.print();
 printWindow.close();
}
// -->
</script>

</form>

No comments:

Post a Comment

If any doubt?then please comment in my post

How to reduce angular CLI build time

 Index: ----- I am using angular cli - 7 and I am going to tell how to reduce the build time as per my knowledge. Problem: -------- Now the ...