Solved

ASP - print button or print image

Posted on 2014-04-23
6
983 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 33

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

820 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