Improve company productivity with a Business Account.Sign Up

x
?
Solved

ASP - print button or print image

Posted on 2014-04-23
6
Medium Priority
?
1,177 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:Aleks
5 Comments
 
LVL 55

Accepted Solution

by:
Scott Fell,  EE MVE earned 1000 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 34

Assisted Solution

by:Big Monty
Big Monty earned 1000 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:Aleks
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:Aleks
ID: 40095725
Sorry for the delay
0

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
These seven tips can help you create an extraordinary website, one that captivates audiences and has them wanting to return regularly for more. Keep reading to find out what your site is missing and what you need to add!
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

607 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