Link to home
Start Free TrialLog in
Avatar of DerekWatling
DerekWatlingFlag for South Africa

asked on

Printing slected contents

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?
Avatar of DerekWatling
DerekWatling
Flag of South Africa image

ASKER

Disregarding re-using the data, I have set up a new page which I can use for the souce of the IFRAME and moved the onload="print()" into the body tag of this page. I just want to print the contents of the IFRAME! However this prints the the whole page with everything around the IFRAME. Due to all the bastards (I'm being polite as this is a public forum) out there using popups for annoying purposes and subsequent proliferation of popup blockers together with the issue of the popup windows becomming hidden behind other windows or opening in a tab rather than as a popup I really DON'T want to use popups. I also must not lose the original window so just loading a new page for printing isn't an option.
ASKER CERTIFIED SOLUTION
Avatar of Infinite_Recursion
Infinite_Recursion

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Pretty much the conclusion that I had come to. More information on the javascript popup would be helpful.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the link. However this seems to be the same as the AJAX ModalPopupExtender that I am already using (and having issues with): I can't get it to go directly from 1 ModalPopup to another and when printing the background page still shows. Might get around the second problem by using a background image instead of a background colour as most browsers are set to print images.
Avatar of Infinite_Recursion
Infinite_Recursion

It is not intended to show multiple layers of modal dialogs, that would be against the idea of modal I guess. Why do you need multiple layers? It is different from the AJAX extender, it can display another page like iframes do.
I don't want to show multiple layers of modal dialogs, what I wanted to do was as the first dialog closes immediately open a second dialog with the report. I can generate the report in a new page or on the same page, that isn't the issue. The biggest problem is when it comes to print. With an IFRAME or Modal Dialog or AJAX ModalPopup IE7 (and I presume other clients) still wants to print what is displayed on the screen rather than just the contents of the current "object".
yes as I said, that is the case, that is also why we use reporting tools, and that is why reporting tools vendors can sell their products instead of going out of business cause everyone is using simple html.
A clarification, reporting tools do alot more than just that, so scratch my last comment abt them :)
Unfortunately budget and time constraints are not conducive to implementing a reporting tool at this stage. The requirements also involve including a map image from a GIS system. I don't know if or what issues specific reporting tools might have with that. Due to an ultimatum that something has to launched by Christmas, I have come to the conclusion that for now we will just have to deal with popup blockers. In the new year I will be able to investigate and improve further. So unless there is a simple, cheap solution ...
I won't scrach your comment about reporting tools, just read it in context as not the be-all and end-all.
OK here is a thought, if you use the link i gave you, and use the javascript dialog, you can set the background to any thing like a totally white background, thus hiding the other content on the page.
I will have a look, but just setting a background-color or background-image doesn't work as most clients are set not to print backgrounds :-{ so when you comne to print the solid background you see on the screen becomes transparent and it looks like 2 pages overprinted. It would need to be a full image in an absolutely positioned div and then I don't know if this can be done or  just how big to make the image so it always covers everything.
Infinite_Recursion
No one else is giving any input on this and you have gone out of your way to answer what you can so the points are comming to you even if I didn't get the type of solution I was hoping for. Thanks for everything.
Derek