Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How can I print the content of an ASP.NET page (C#)?

Reply
Thread Tools

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

 
 
Steve Kershaw
Guest
Posts: n/a
 
      10-13-2006
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

 
Reply With Quote
 
 
 
 
apathetic
Guest
Posts: n/a
 
      10-13-2006
Steve Kershaw wrote:
> 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

 
Reply With Quote
 
 
 
 
Bruno Alexandre
Guest
Posts: n/a
 
      10-13-2006
<asp:button ... onClickClick="javascript: window.print();" ... />

--

Bruno Alexandre
KÝbenhavn, Danmark

"a Portuguese in Denmark"

Blog. http://balexandre.blogspot.com/
Photos. http://www.flickr.com/photos/balexandre/


"Steve Kershaw" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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
>



 
Reply With Quote
 
Steve Kershaw
Guest
Posts: n/a
 
      10-13-2006

apathetic wrote:
> Steve Kershaw wrote:
> > 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

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

 
Reply With Quote
 
=?Utf-8?B?QW5kcmU=?=
Guest
Posts: n/a
 
      10-13-2006
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?

"Steve Kershaw" wrote:

>
> apathetic wrote:
> > Steve Kershaw wrote:
> > > 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

> 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
>
>

 
Reply With Quote
 
apathetic
Guest
Posts: n/a
 
      10-14-2006
Andre wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz ASP .Net 6 06-09-2010 01:54 PM
document.getElementById(), error in content page content page Dave L ASP .Net 3 03-04-2010 08:50 AM
Error: "Content controls can only be used in a content page" J.Edwards ASP .Net 0 01-20-2006 11:43 AM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments