•
•
•
•
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
![]() |
•
•
Join Date: Sep 2006
Posts: 105
Reputation:
Rep Power: 3
Solved Threads: 0
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
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
•
•
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,166
Reputation:
Rep Power: 7
Solved Threads: 59
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
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.
look into CSS
<style type="text/css" media="print">#elementid {display; none;}</style> 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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- draft print in asp.net 2.0 (ASP.NET)
- How do i print asp page on client side "only the contents" (ASP)
- Printing using Web Control Print button VB.NET (JavaScript / DHTML / AJAX)
- Dynamically Print Out Structure Contents (C++)
- Silent Print a PDF from VB.NET (VB.NET)
- Run-time Error when printing Array Contents. (C)
Other Threads in the ASP.NET Forum
- Previous Thread: Looking for ASP.NET
- Next Thread: Socket Programming



Linear Mode