Solved

ASP - print button or print image

Posted on 2014-04-23
6
938 Views
Last Modified: 2014-05-28
I have an ASP page that I need to print. User can right click on the page and select 'print' and this is ok, but I want to add an icon to print the page. If simply add an image with javascript then the icon is also printed along with the ASP page.
I want to add either an image or a button that sends the ASP page to the printer but does NOT print the icon (image) or the button.

How can I do this ?
0
Comment
Question by:amucinobluedot
6 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 250 total points
ID: 40017934
Create a css for print http://www.w3schools.com/css/css_mediatypes.aspa and set the class of the print button to not display for print.  You could create a separate page for printing but that is extra work.

@media print
  {
  .print_button {display:none}
  }

Open in new window

0
 
LVL 32

Assisted Solution

by:Big Monty
Big Monty earned 250 total points
ID: 40017974
since you want an actual button or image to print the page, I would open up the page in a modal window, then in the load event of the modal dialog, you can use window.print() to open up the printer dialog window.

so on your main page, you would have something like:

<input type="button" value="Print" onclick="window.open( '/printPage.asp' );" />

and in printPage.asp, you add the following line to your onload event of the page:

window.print()

if you want everything on the same page, you could do something like this (if you don't want to go the css route Scott Suggested:

<input id="printMe"  type="button" value="Print" onclick="printPage()" />

and your function would look like:

function printPage() {
     //-- hide the button (and whatever else you don't want shown
     document.getElementById('printMe').display = 'none';

    //-- window.print();
}
0
 

Author Comment

by:amucinobluedot
ID: 40018352
Thank you. I will give this a try
0
 
LVL 58

Expert Comment

by:Gary
ID: 40095724
I've requested that this question be closed as follows:

Accepted answer: 500 points for padas's comment #a40017934

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 

Author Closing Comment

by:amucinobluedot
ID: 40095725
Sorry for the delay
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Read about why website design really matters in today's demanding market.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now