Printing, then refreshing the form

On one of my pages, I have some data inside an ASP.net Repeater, that I have done custom data-paging in to break up a report view into chunks.  However, when I print it, I want to print the whole thing at once.  Here’s what I came up with.

First the C# code for the Print button: (Code)

printingcs

In a nutshell, it’s forcing the report section of the page to render with paging disabled (show the whole report), and then calling a javascript function defined in the page itself which prints the page and then re-submits the form to re-render the paged version of the report.  Here’s the javascript portion:  (Code)

printingjs

This is pretty straightforward, other than the delay part.  When I initially tested this in FireFox without the delay, it worked great. Then I switched over to IE7 and noticed that the submit was occurring before IE could bring up the Print Page dialog and so it never printed (basically it did nothing other than flicker the page a bit due to the two postbacks).  So I did a quick google search on how to delay in javascript and used this as a guide.

Advertisements

0 Responses to “Printing, then refreshing the form”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Scott’s recent tweets…


%d bloggers like this: