Revision #2

You are currently reviewing an older revision of this page.
Go to current version
Requirement: Print only the content inside of Div in ASP.NET.

Solution:
For printing the page, there is a Javascript function: window.print(). However, it will print whole page. If you need to print only the content of Div, then you have a few options available, but the maximum is either using IFrame or the Window.open() popup and then using window.print() to print the div content.

You can use JavaScript to open div content in a popup and then print it. See this solution here:
http://geekiest.net/post/Print-the-content-of-a-div-using-JavaScript.aspx

Another option is to use IFrame. See more about that here:
http://www.isolutionteam.co.uk/printing-contents-of-a-div-using-javascript/

The recommended option is to use JQuery:
http://www.bennadel.com/index.cfm?event=blog.viewcode&id=1591&index=1
It uses the jquery.print.js plugin and works great.


This article was originally written by Jayant.

Revert to this revision