Print A Div On Place of Full page in Asp.net

Step 1> Give a Id to your Div which you want to print

EX-<div id="abc"> hello sir</div>

Step 2> Add these code any where in your <html> section 

<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>

Step 3> Put a html input button for print option

<input type="button" value="Print" onclick="JavaScript:printPartOfPage('abc');"/>


where 'abc' is Div Id , you can put you Div Id that you given in your Code.
Ebook Download
View all
Learn
View all