User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,534 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,041 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1774 | Replies: 1
Reply
Join Date: Sep 2006
Posts: 105
Reputation: bhavna_816 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bhavna_816 bhavna_816 is offline Offline
Junior Poster

How to print specified contents in .NET 2.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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,166
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 59
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: How to print specified contents in .NET 2.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
<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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 4:43 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC