interviews.dotnetthread.com

↑ Grab this Headline Animator

Tuesday, August 26, 2008

How to print a DataGrid content Alone from an ASP.NET Web Page using javascript?

If Asp.Net page contain dtagrid content with some other content we want
to print only datagrid content then there are two ways to do:

Place the code withtin function tag of the javascript and call from the asp.net page
1>
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();

2>By using the display property of the content
document.getElementById('idOfhtecontent').display='none';
Window.print();
Window.close();

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles