Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    printing a listbox

    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?

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Did you solve this?
    If not, do you need it to really print, or did you just want the button with an empty handler?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    New Coder
    Join Date
    Jan 2007
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #6
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #7
    Regular Coder
    Join Date
    Sep 2006
    Location
    Skopje, Macedonia
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool The solution

    Code:
    <A HREF="javascript:window.print()">Click to Print This Page</A>


    Works!

    Regards!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •