How do I print the contents of a table ( c#)?

I have a simple page with a table with some images, a table with some data. I would like ot print it out. I have an image button that I would like to use to print it. How would I do that?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

try put this javscript code to your button:
dbruyereAuthor Commented:
I noticed the window.print() suggested elsewhere, but I don't know how to add that to my button.
are you using asp:ImageButton? In this case if so try this in your c# code:

or if you are using HTML button, try this:
<button onclick="window.print()"><img src="your image"></button>
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

dbruyereAuthor Commented:
it is an asp:ImageButton. Thank you very much. I will try after this reboot.
sorry dbruyere, should be
ImageButton1.Attributes.Add("onclick","window.print();return false;");

return false is to tell the form not to postback to server.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason ScolaroCommented:
Hi dylanyee,

Just as a nice alternative if you were using .NET 2.0, for the ImageButton you could do this, without the need for code-behind:
<asp:ImageButton runat="server" ImageUrl="print.gif" OnClientClick="window.print(); return false;" id="imgPrint" />

Good luck!
-- Jason
dbruyereAuthor Commented:
Thank you very much. I had to also had to change viewstate to false for some reason.  But that is working great. Is there any way to exclude the print button from showing on the printed page?
dbruyere, since your question is a new question, please ask it on the new thread.
I can only hint you that you can use style sheet to achieve that. while printing, use another set of CSS which will hide the button. good luck ;)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.