window.print() and postpack, how both works?

U

Umut Tezduyar

In the msdn.microsoft.com/library most of the articles have an "print"
option. But the "print" button is different from the javascripts
"window.print()" method. It postpacks the page and then invokes the
window.print () method. I couldn't found out the way it works. I need to do
something like this, can any body help me?

Also, i got a collection, and i want to print each of the items in the
collection to a seperate page. If i do it with the <div> tags and arrange
the height of it, is it same as for all different printers. Is there another
way for it.
 
A

Anders Norås [MCAD]

In the msdn.microsoft.com/library most of the articles have an "print"
option. But the "print" button is different from the javascripts
"window.print()" method. It postpacks the page and then invokes the
window.print () method. I couldn't found out the way it works. I need to
do something like this, can any body help me?

Emit the javascript code to print the page in the click event handler. Like
this:
protected void Button_Click(object sender, System.EventArgs e) {
Page.RegisterStartupScript("PrintPage","<script
Also, i got a collection, and i want to print each of the items in the
collection to a seperate page. If i do it with the <div> tags and arrange
the height of it, is it same as for all different printers. Is there
another way for it.

Use the page-break-before or page-break-after CSS styles to control page
breaks when printing.

<HR style="page-break-before: always;">
<!--- HTML to be on the page -->

You cannot use the window.print() method to print the contents of a
collection. Therefore you'll have to render each element as HTML. Use HTML
code similar to the example above to force page breaks.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
D

Dimitri Glazkov

Umut,

Why not just use window.print()? Do you really need to have another
postback?

:DG<
 
U

Umut Tezduyar

Thank you a lot.
This really helped me a lot.

Anders Norås said:
Emit the javascript code to print the page in the click event handler.
Like this:
protected void Button_Click(object sender, System.EventArgs e) {
Page.RegisterStartupScript("PrintPage","<script


Use the page-break-before or page-break-after CSS styles to control page
breaks when printing.

<HR style="page-break-before: always;">
<!--- HTML to be on the page -->

You cannot use the window.print() method to print the contents of a
collection. Therefore you'll have to render each element as HTML. Use HTML
code similar to the example above to force page breaks.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top