Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keep button(s) from printing 1

Status
Not open for further replies.

xenology

Programmer
May 22, 2002
51
US
I have a simple asp.net form that allows the user to update a couple of fields. one of the buttons is a print button (required by client - they don't like the toolbar print button) so I have at the top of page_load

btnPrint.Attributes.Add("onclick", "window.print();")

My question is, how can I keep all the buttons (4) on the form from printing when the user prints from this click button?

TIA!
xeno
 
hmmm I'm not sure this works but it's something u may try...

How about hiding the buttons, calling print, and then showing the buttons again?

Something like this:

Code:
btn.Attributes.Add("onclick", "MyPrint();");

[green]// A javascript function[/green]
[blue]function[/blue] MyPrint()
{
   btn1.style.display='none';
   btn2.style.display='none';
   ...
   window.print();
   btn1.style.display='block';
   btn2.style.display='block';
   ...
}
This is definitely not the most elegant way to your problem and, like I said, I'm not even sure it works, but you may give it a shot!

JC

_________________________________________________
To get the best response to a question, read faq222-2244.
 
JC

With a small code modification it works great! Thanks!!!
<code>
document.Form1.item('btnPrint').style.display='none';
document.Form1.item('btnReturn').style.display='none';
<\code>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top