Printing slected contents
Posted on 2007-11-27
I need to generate a reports for printing and emailing. I plan on doing this in HTML using CSS for page breaks, etc. I already have the data on the page and have stored it in a Public Shared DataRow variable so that I don't need to re-query the database. Our current (Classic ASP) system brings up the report in a new popup window and re-queries the database. Not only does this put tremendous strain on the server but our support department receives numerous calls from clients who have problems because of (multiple) popup-blockers running on their browsers.
When a user clicks on the "Print" (or "Email") button I open a ModalPopup where they can select which reports they want to print and then click "Print". The system must now take the stored data and reformat it with the user's information on the top of each page, at an appropriate width for printing, with page breaks, etc... I am using a StringBuilder and then assigning the results to a Label control.
I first tried doing this in a second ModalPopup, but had problems with the server side routines not running with the first ModalPopup immediately trying to call a second one. Also not sure how I would have got it to print just the contents of a ModalPopup. The page already uses TabPanels, so I have thought of putting a <IFRAME> into a new tab. This introduces 2 problems:
1) I have an IFRAME containing a Label and want to set the contents via the Label rather than the "src" of the IFRAME.
2) If I simply add onload="print()" to the IFRAME the client print dialog comes up when the page first loads, even though the TabPanel is not visible at this stage.
How can I get around these issues using the data I already have stored? Is there a better way to tackle this scenario?