How can I print the content of an ASP.NET page (C#)?

  • Thread starter Thread starter Steve Kershaw
  • Start date Start date
S

Steve Kershaw

Hello,

I have a web page with a coupon that I would like to print when the
user clicks on the "print" button. How can I do this in C#?

Thanks
Steve
 
Steve said:
I have a web page with a coupon that I would like to print when the
user clicks on the "print" button. How can I do this in C#?

You are going to need to clarify here. Are you trying to make an
ASP.NET print button in C#? The only way to send the print command to
the browser would be to render out some Javascript saying
window.print() in one of your event handlers.

Tim
 
apathetic said:
You are going to need to clarify here. Are you trying to make an
ASP.NET print button in C#? The only way to send the print command to
the browser would be to render out some Javascript saying
window.print() in one of your event handlers.

Tim
Thanks that solved the problem!
I just entered window.print() in the "OnClientClick" textbox in the
Properties for the <asp:Button...> control and that did the trick!

Thanks again Tim
Steve
 
Hi, did this simply print the page as if you would click file and print, or
are you able to print only certain objects on a form for instance?
 
Andre said:
Hi, did this simply print the page as if you would click file and print, or
are you able to print only certain objects on a form for instance?

Javascript window.print() just calls the print command of the browser,
so you get the whole page. You would need to use CSS with
media="print" set, or spawn a new browser window in order to
selectively print your content.

Regards,
apathetic
 
Back
Top