Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi friends,

i would like to print a webform,i used a button to print.
How can i hide the button while printing the page?

Srinivas Vadepally
Posted
Updated 8-Sep-11 1:52am
v2

Add following style in head tag of the web page

HTML
<style type="text/css" media="print">
        .PrintStyle { display:none; }   
</style>


and then use this class in your button as follows

HTML
<input type='button' id="btn1" value='Print'  class='PrintStyle' />
 
Share this answer
 
C#
$('#btn1').click(function(){
    this.css("visibility","hidden");
    window.print();
    this.css("visibility","visible");
});


*btn1 is the id of the button.

* Don't forget to add a reference to jquery above in your document.

* If you want to print some div or some part of the html document and not the whole document. Visit:
http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/[^]

* If you need any other support do let me know.

I hope I answered your question.

Watch my first article posted on codeproject and comment and vote:
http://www.codeproject.com/KB/HTML/speechinputapi.aspx
or http://blog.robinrizvi.info

Drop me a mail for any comments, suggestions or questions.
mail@robinrizvi.info
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900