| | |
How to print specified contents in .NET 2.0?
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2006
Posts: 116
Reputation:
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
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
ASP.NET Syntax (Toggle Plain Text)
<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.
![]() |
Similar Threads
- 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
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child class click commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose feedback flash flv form formatdecimal forms formview google grid gridview homeedition hosting iframe iis javascript jquery list login menu microsoft mono mssql multistepregistration nameisnotdeclared numerical objects order panelmasterpagebuttoncontrols problem ratings rotatepage save schoolproject search security serializesmo.table silverlight smartcard sql sqlserver2005 suse textbox tracking typeof unauthorized validation vb.net video view virtualdirectory vista visual-studio visualstudio web webarchitecture webdevelopemnt webservice wizard xml youareanotmemberofthedebuggerusers






