ASP.NET - Print div content using C# code - Asked By Gunasundari Loganathan on 09-Apr-13 03:06 AM

hi all,

I have to print the div content of a web page using C#. Can any one help me Thanks in advance
Sathish S replied to Gunasundari Loganathan on 11-Apr-13 01:59 AM
Here is a way to achieve this

<div id="printableArea">
    <h1>Print me</h1>
<input type="button" onclick="printDiv('printableArea')" value="print a div!" />
function printDiv(divName) {
   var printContents = document.getElementById(divName).innerHTML;
   var originalContents = document.body.innerHTML;
   document.body.innerHTML = printContents;
   document.body.innerHTML = originalContents;