Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Printer Friendly New ASP.Net Page

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-05-02 : 14:53:29
Hi Group:

I have a project that need it a new ASP.Net page Printer Friendly page. So this is what I did:
1. I used the Parent Page


function PrintThisPage()
{
var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,";
sOption+="scrollbars=yes,width=730,height=700,left=100,top=25";

var winprint=window.open("MSDSPrint.aspx","Print",sOption);

winprint.focus();
}

</script>

<div id="contentstart">


And then I created a New Page called MSDSPrint.aspx



<script language="JavaScript">
function GetPrintContent()
{
var PrintDiv = document.getElementById('printcontent');
var ContentDiv = window.opener.document.getElementById('contentstart');
PrintDiv.innerHTML = ContentDiv.innerHTML;
}
</script>



And called the Parent Page....
Everything seems to work perfect. The new window open and contains all the 250 records that I need to print. The problem is that when I try to print the records is only printing the first page for a total of 4 pages. If you look in the previous print you can only see the records that fit in the first page and all the others are blank.

I NEED HELP!!!!!!!!!!!!!!! THANKS!!!!!!!!!!!!

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-05-02 : 17:33:13
I am concern, nobody knows the answer :(
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-05-05 : 17:52:45
? ? ? ? ? ?
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-05-05 : 19:35:22
Do you think you have given us enough information so we can help you?

Read this sentence:

"The problem is that when I try to print the records is only printing the first page for a total of 4 pages."

Does that make any sense to you? You need to clearly and precisely explain exactly what is happening. And, you need to understand that this is a MICROSOFT SQL SERVER FORUM, not an HTML or web design forum. There's about 4 of us here that can help you, whereas if you actually go to a forum that is for this stuff, there may be more people who can provide assistance.

In short -- if you are wondering why no one is helping you, consider stopping and thinking about why that may be ....

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-05-06 : 10:26:47
jsmith8858

I think the problem is that is printing the records that fit within the new Window document. It's not printing the document, is printing the window.
Ok. winprint.focus();

How can I print the document? So it will include the other 3 pages. I hope that is clear enought.

Thanks,
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-05-06 : 10:31:45
No, it is not clear. What document are you talking about? What records are you talking about? None of those concepts make any sense in the context of a web page without specific details.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-05-06 : 10:41:21
Well, Thanks for the help
Go to Top of Page

uberman
Posting Yak Master

159 Posts

Posted - 2008-05-06 : 11:33:26
As Jeff says, not really clear at all... but you could investigate the following...

It might be worth investigating print style sheets, so you dont even need to pop the window (http://www.google.com/search?q=css+media+print)

Sticking with pop up approach, have you used multiple browsers to see if they all act the same (IE, FireFox, Safari)... looking at the JS code that rips the HTML from the parent to inject into the child and then getting it to print it all if you find issues with how this is handled you might need another solution...

...such as re running the page generation to product printer friendly output (or having a look at my first suggestion)
Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-05-06 : 12:43:46
Thanks I found a solution for the problem. :)

I'll give it to the everybody so they can do use it in the future.


function PrintThisPage()
{
var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,";
sOption+="scrollbars=yes,width=750,height=600,left=100,top=25";

var sWinHTML = document.getElementById('contentstart').innerHTML;

var winprint=window.open("","",sOption);
winprint.document.open();
winprint.document.write('<html><LINK href=/eggheadcafe.css rel=Stylesheet><body>');
winprint.document.write(sWinHTML);
winprint.document.write('</body></html>');
winprint.document.close();
winprint.focus();
}

http://www.eggheadcafe.com/articles/20030627a.asp

THE BEST INFORMATION I HAVE FOUND SO FAR....
Go to Top of Page
   

- Advertisement -