Header Ads

Print specific grid view in the page.

Function of the JavaScript:


function PrintDiv(IdOfDivToPrint)
{
var myContentToPrint = document.getElementById(IdOfDivToPrint);

var myWindowToPrint = window.open('','','width=200,height=100,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,directories=0');
myWindowToPrint.document.write(myContentToPrint.innerHTML);
myWindowToPrint.document.close();
myWindowToPrint.focus();
myWindowToPrint.print();
myWindowToPrint.close();
}



ASP code in the page to display the controls:


< asp:button id="PrintButton" runat="server" onclientclick="javascript:PrintDiv('DivToPrint')" text="Click Here To Print" visible="true" / >
< br / >
< br / >
< div id="DivToPrint" runat="server" visible="true" >
< asp:gridview id="MainGridView" runat="server" >
< /asp:gridview >
< /div >

No comments:



Powered by Blogger.