Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am doing Result publication academic project. I want to print the received result using print button. on clicking print button result form must be printed.Please any simple idea for print. kindly share the code in .aspx Thank you
Posted

use Window print() Method[^]
DEMO[^]

window.print with asp.net button:
ASP.NET
<asp:Button ID="printButton" runat="server" Text="Print" OnClientClick="javascript:window.print();" />
 
Share this answer
 
v2
The user already has a print button on their browser, you don't need to supply one.

If you want something like a print-preview then you can use css media queries to apply a print stylesheet to the page and use window.print to invoke the print dialogue

http://www.granneman.com/webdev/coding/css/printfriendlythemcvicarmet/[^]

http://www.htmlgoodies.com/beyond/javascript/article.php/3471121[^]

To pre-empt your next question, no you can't print without asking the user to confirm.
 
Share this answer
 
You can find the solution here
http://stackoverflow.com/questions/16033634/how-to-print-part-of-the-page-in-asp-net
 
Share this answer
 
v2
Just to add my 2cents.

It's a good idea to include a print css setting. That way you can present the browser with a nicely formatted page for the user, and a second formatted for the printer (i.e. remove menus, images and links etc...)

The way to do this it to specify @Media in the css settings:

Here are a couple of articles that should explain in more detail ^_^

Print a doument with CSS[^]

Printing with Style[^]

No need to accept this. I only post as an FYI.

Good luck :)
 
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