Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to print the content of an aspx page using a printer. Can you provide solution for this..........
Can u give the entire code to do this....
Posted
Updated 18-Jul-10 20:17pm
v2

there's a print method in Javascript,that's about all you can do.
 
Share this answer
 
Have a look at this article:
How to Print in ASP.NET 2.0[^]
 
Share this answer
 
I have this need to code this. However, the "two" solutions above are about the only way I have found to do this. The problem stems around the "viewstate". Once a page loads the view state is set, and if a user needs to fill out some items and then you want to allow them to print, oops, you have a view state gotcha. So for printing a page after page load, and after a user fills in some form data, then.
1. Put your page out there for user to input.
2. Print button calls asp page using postbackurl. target = _blank, making a popup.
3. On that new page load, use previous.page to fill in the data.
4. From here you can use any method you want, Like that ASP article in Solution #2 or you can use the JavaScript document.print() like Solution #1. And for both you want to have a "onload print call" in the body tag of the page.

Kind of involved, the problem stems from the "viewstate" after a page loads. You could probably code something to change viewstate values of all your items, but, crackers, that would be more time than I have right now.
 
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