How to print specified contents in .NET 2.0?

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 116
Reputation: bhavna_816 is an unknown quantity at this point 
Solved Threads: 0
bhavna_816 bhavna_816 is offline Offline
Junior Poster

How to print specified contents in .NET 2.0?

 
0
  #1
Oct 11th, 2007
I want to print the page in C#/ASP.NET 2.0, but the problem is when i use following javascript code, it prints the whole page.

function printMe()
{
window.print();
document.getElementById("printed").value = "YES";
document.getElementById("form1").submit();
}
<formid="form1"runat="server">

<input type="button" value="Print me" onclick="printMe();" />
<input type="hidden" id="printed" />

I don't want to print the complete page but i just want to print the contents of the page only.
Do anybody have any idea?

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: How to print specified contents in .NET 2.0?

 
0
  #2
Oct 11th, 2007
You have a couple of choices depending on how many elements you require to print. There is no 'builtin' solution for this kind of thing in ASP.NET

look into CSS
  1. <style type="text/css" media="print">#elementid {display; none;}</style>
You can have a separate style sheet for the browser to apply when printing, which hides any elements you don't want in the print out, by applying display: none style to them.

The other option is appending the elements you want printed into an iFrame thats positioned out of site in the page and print from that.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC