Printing from ASP.NET1.1

K

karch

I'm not sure if this is even possible, but the scenario is this:

I have a web page which will have options for printing different kinds of
form letters (think dropdown list). Once a letter is selected and a "Print"
button is clicked, I need to be able to bring up a Print Dialog to let the
user select a printer. Then, I need to send the print data to the printer.
The catch here is that I don't want to have to show the letters, I would
just like to send the text/html to the printer once the type of letter and
printer has been chosen.

Is this possible? How would I go about doing this?

Thanks!
 
N

Nathan Sokalski

Well, I don't know if there is a way to do what you want using only ASP.NET
(I think you would need something like an ActiveX control or something), but
here is a workaround that uses just ASP.NET and JavaScript. Create another
page that has the following body tag:

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

This page will have the content (and only the content) you want printed.
When the user clicks the print button on the page they selected the form
from, this page will open IN ANOTHER WINDOW. after it opens, they will see
the print dialog, select the printer, and then the window will close,
therefore having the page get printed, but they will never have to manually
open or close the extra window. If you want to go the extra mile, you could
also add JavaScript to make the window as small as possible so that they
don't even notice that another window opened, like the following:

<body onLoad="window.resizeTo(0,0);window.print();window.close();">

This is what I do when I don't want any extra buttons or controls printed
with a page on my site, so you can see how well it works for you. Good Luck!
 
K

karch

Excellent idea...I'll give it a try!

Thanks!

Nathan Sokalski said:
Well, I don't know if there is a way to do what you want using only ASP.NET
(I think you would need something like an ActiveX control or something), but
here is a workaround that uses just ASP.NET and JavaScript. Create another
page that has the following body tag:

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

This page will have the content (and only the content) you want printed.
When the user clicks the print button on the page they selected the form
from, this page will open IN ANOTHER WINDOW. after it opens, they will see
the print dialog, select the printer, and then the window will close,
therefore having the page get printed, but they will never have to manually
open or close the extra window. If you want to go the extra mile, you could
also add JavaScript to make the window as small as possible so that they
don't even notice that another window opened, like the following:

<body onLoad="window.resizeTo(0,0);window.print();window.close();">

This is what I do when I don't want any extra buttons or controls printed
with a page on my site, so you can see how well it works for you. Good Luck!
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top