View Full Version : printing a listbox

04-02-2007, 03:10 PM
i ahve a list box with informnation in and want to print the information when a command button is pressed. my pages are aspx pages in visual studio.

my project is a website and so i cannot find a way of adding a print dialog which is possible whwne using a project.

can anyone sugest any code to print the list boxes please?

04-02-2007, 10:31 PM
Well, a web application would have to use javascript to print something from the client. A forms app is already running on the client; this is not quite the same for a web app. If you know your users and know they have a printer, you can make a simple little button that has onclientclick="window.print" type thing and use some nice CSS to control what prints and the style.

If this is not an intranet app, just be aware that not everyone has a printer. Mine's been broken for months. :)

04-03-2007, 11:48 PM
this is just a prototype that i am creating for a project which i will need to give a small demo of, the print function will not be neccesary to show but i will need the code there.

the website will not be going live, its just a demo :)

04-04-2007, 09:09 PM
Did you solve this?
If not, do you need it to really print, or did you just want the button with an empty handler?

04-09-2007, 10:56 PM
i dont actually need it to print in the demo, but i need the code there to show that it would be avble to print for academic purposes. any suggestions?

04-10-2007, 10:51 PM
I'd just "cheat" for the demo. :)

A plain, non-aspx button with an onlick="window.print()", and a css stylesheet to set up the print styles to hide everything except form.select-one elements.

<input type="button" value="Print" onlick="window.print()" />

If you have other selects besides the ones you want to show up on paper, you may need to add a class name or something.
I hate to spend too much time for demos...

If it isn't even going to actually print, the button will bring up the printer dialog, you can even skip the CSS.

04-11-2007, 03:32 PM
<A HREF="javascript:window.print()">Click to Print This Page</A>