IT Community - Software Programming, Web Development and Technical Support

How Create print preview page dynamically in ASP.NET

This is a discussion on How Create print preview page dynamically in ASP.NET within the ASP and ASP.NET Programming forums, part of the Web Development category; Hi, I want to show a print preview page before printing the page, then I have to make a page ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:49 PM
KiruthikaSambandam KiruthikaSambandam is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 332
KiruthikaSambandam is on a distinguished road
Default How Create print preview page dynamically in ASP.NET

Hi,

I want to show a print preview page before printing the page, then I have to make a page like that currently is showing.

and I want to print a particular section of that page like only Data Grid, HTML Table, or any others section.

How to do this ?

Thanks
KiruthikaSambandam
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-29-2008, 05:05 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: How Create print preview page dynamically in ASP.NET

hi
Check this link
How To Print a Data Grid in C# and .NET
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-05-2008, 02:44 AM
rrrajesh84in rrrajesh84in is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 399
rrrajesh84in is on a distinguished road
Default Re: How Create print preview page dynamically in ASP.NET

hi

check this link.

it really helps u.

CodeProject: Creating print preview page dynamically in ASP.NET. Free source code and programming help
__________________
.....................................
''''''
Rajesh''''''
Ants. . . . . . Like me
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-20-2008, 09:31 PM
GDevakii GDevakii is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 138
GDevakii is on a distinguished road
Smile Re: How Create print preview page dynamically in ASP.NET

function getPrint(print_area)

{

//Creating new page

var pp = window.open();

//Adding HTML opening tag with <HEAD> … </HEAD> portion

pp.document.writeln('<HTML><HEAD><title>Print Preview</title>')

pp.document.writeln('<LINK href=Styles.css type="text/css" rel="stylesheet">')

pp.document.writeln('<LINK href=PrintStyle.css type="text/css" rel="stylesheet" media="print">')

pp.document.writeln('<base target="_self"></HEAD>')

//Adding Body Tag

pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0"');

pp.document.writeln(' leftMargin="0" topMargin="0" rightMargin="0">');

//Adding form Tag

pp.document.writeln('<form method="post">');

//Creating two buttons Print and Close within a HTML table

pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right>');

pp.document.writeln('<INPUT ID="PRINT" type="button" value="Print" ');

pp.document.writeln('onclick="javascript:location. reload(true);window.print();">');

pp.document.writeln('<INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();">');

pp.document.writeln('</TD></TR><TR><TD></TD></TR></TABLE>');

//Writing print area of the calling page

pp.document.writeln(document.getElementById(print_ area).innerHTML);

//Ending Tag of </form>, </body> and </HTML>

pp.document.writeln('</form></body></HTML>');

}

'calling getPrint() function in the button onclick event
btnPrint.Attributes.Add("Onclick", "getPrint('print_area');")
btnTablePP.Attributes.Add("Onclick", "getPrint('Print_Table');")
btnPagepp.Attributes.Add("Onclick", "getPrint('Print_All');")
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-21-2008, 04:42 AM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: How Create print preview page dynamically in ASP.NET

<script type="text/javascript">
var gridViewCtlId = '<%=GridView.ClientID%>';
function Print()
{
//assuming that this is the generated ID
var grid_obj = document.getElementById(gridViewCtlId);
if (grid_obj != null)
{
var new_window = window.open('print.html'); //print.html is just a dummy page with no content in it.
new_window.document.write(grid_obj.outerHTML);
new_window.print();
new_window.close();
}
}
</script>
You could also comment out the print() and close(), this way user will have a ‘print preview’ and has the chance to set margin, header/footer of the print out.
__________________
Shaalini.S
Be the Best of Whatever you are...

Last edited by shaalini : 03-21-2008 at 04:53 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can we Dynamically create web controls Kirubhananth ASP and ASP.NET Programming 3 03-14-2008 10:00 PM
Code-behind to create node dynamically using XML File or any Stored Procedure poornima ASP and ASP.NET Programming 3 02-14-2008 09:46 PM
Preview Image before Uploading File to Server velhari HTML, CSS and Javascript Coding Techniques 1 11-12-2007 10:21 PM
Create database object with dynamically S.Vinothkumar C# Programming 6 09-28-2007 11:49 PM
how to print iframe pdf document using file print menu using javascript kingmaker HTML, CSS and Javascript Coding Techniques 1 08-22-2007 05:32 AM


All times are GMT -7. The time now is 11:22 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0