By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

one Page print another n times?

P: n/a
bob
Hi,
I have a page that has a collection of things which it passes to a
second 'print' page using a session variable.

The print page has buttons for moving though the collection and the
user prints by using the browser print button then moves to the next
one in the session collection.

All very tedious but I know no better.

The missing pieces of my puzzle;
1) How do you programatically print with ASP.net?

2) Ideally the print page would update from the session variable
and print itself n times until all members of the collection have been
printed.

Is this possible?

I am getting the feeling that I need to use Javescript seeing I am
essentially asking for a client side action.

If so is there a Javescript tutorial or book you would recommend for
someone who has never used it.
thanks
Bob
Oct 22 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
The most important JavaScript method you will need to use is the
window.print() method. From what I can tell, you will need to create an
ASP.NET Page that the user never actually uses, but is the one that does the
printing. If this sounds confusing, see if this helps:

1. Create an ASP.NET Page that accepts any necessary parameters using a
querystring. This Page will include the JavaScript window.print() and
window.close() methods in the JavaScript onload eventhandler as follows:

<body onload="window.print();window.close();">

This will cause the Page to print and close without the user needing to do
anything.

2. In your initial page that you want the user to see, generate the
following JavaScript for each item you want to print:

window.open('http://www.yoursite.com/printpage.aspx?param1=value1&param2=value2');

By doing this you will be opening the printpage multiple times, but with a
different querystring so that each of your desired items gets printed. I may
not have given the best instructions, but hopefully you are understanding
the technique I am suggesting, and now know the necessary JavaScript to do
it. I would strongly recommend that you learn more about JavaScript, now web
developer will survive very long without it. Even with all the JavaScript
that ASP.NET generates for you, you still need to know the basics for the
sake of debugging, and you will probably need to write some on your own at
some point. A very good book for JavaScript is:

javascript: The Definitive Guide by David Flanagan
http://www.amazon.com/JavaScript-Def...4714359&sr=8-1

Hopefully all this helps. I haven't seen your site, but I would suggest also
considering making a single page that the user can print that contains all
the items, most people don't want to print more pages than necessary. Good
Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"bob" <st**************@cutthis.adriley.co.nzwrote in message
news:h8********************************@4ax.com...
Hi,
I have a page that has a collection of things which it passes to a
second 'print' page using a session variable.

The print page has buttons for moving though the collection and the
user prints by using the browser print button then moves to the next
one in the session collection.

All very tedious but I know no better.

The missing pieces of my puzzle;
1) How do you programatically print with ASP.net?

2) Ideally the print page would update from the session variable
and print itself n times until all members of the collection have been
printed.

Is this possible?

I am getting the feeling that I need to use Javescript seeing I am
essentially asking for a client side action.

If so is there a Javescript tutorial or book you would recommend for
someone who has never used it.
thanks
Bob

Oct 22 '08 #2

P: n/a
bob
Hi Nathan,
Thank you.
That makes it perfectly clear.
Also thanks for the book reference.
regards
Bob

On Wed, 22 Oct 2008 18:29:30 -0400, "Nathan Sokalski"
<nj********@hotmail.comwrote:
>The most important JavaScript method you will need to use is the
window.print() method. From what I can tell, you will need to create an
ASP.NET Page that the user never actually uses, but is the one that does the
printing. If this sounds confusing, see if this helps:

1. Create an ASP.NET Page that accepts any necessary parameters using a
querystring. This Page will include the JavaScript window.print() and
window.close() methods in the JavaScript onload eventhandler as follows:

<body onload="window.print();window.close();">

This will cause the Page to print and close without the user needing to do
anything.

2. In your initial page that you want the user to see, generate the
following JavaScript for each item you want to print:

window.open('http://www.yoursite.com/printpage.aspx?param1=value1&param2=value2');

By doing this you will be opening the printpage multiple times, but with a
different querystring so that each of your desired items gets printed. I may
not have given the best instructions, but hopefully you are understanding
the technique I am suggesting, and now know the necessary JavaScript to do
it. I would strongly recommend that you learn more about JavaScript, now web
developer will survive very long without it. Even with all the JavaScript
that ASP.NET generates for you, you still need to know the basics for the
sake of debugging, and you will probably need to write some on your own at
some point. A very good book for JavaScript is:

javascript: The Definitive Guide by David Flanagan
http://www.amazon.com/JavaScript-Def...4714359&sr=8-1

Hopefully all this helps. I haven't seen your site, but I would suggest also
considering making a single page that the user can print that contains all
the items, most people don't want to print more pages than necessary. Good
Luck!
Oct 23 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.