Tags

, , , ,


Full Page or Partial Page printing in asp.net (.aspx)
Full Page or Partial Page printing in asp.net (.aspx) is very easy; there is two way to print the page.
First way: Create a separate page as printable version of original page and take the print of that very page for full or partial printing.
Second way: Same page use for display contents on screen and print on printer (Full or Partial Page). Let create a webpage for both Screen and Print. Page has Header, Footer, Left Menu and Right Contents Part. Let print the Header, Contents and footer part only we will skip the Left menu In Printing.

Step1:Create a Screen style sheet version for display contents on Screen.

StyleSheet.css
body
{
color: #000;
font: 11pt/20pt, Arial,”Times New Roman”, Times, serif;
}
div#leftMenuDiv
{
display:block;
width:120px;
}

Step2: Create a print style sheet version for printing contents on printer.

Print.css
body
{
color: #000;
font: 12pt/20pt, Arial,”Times New Roman”, Times, serif;
}
div#leftMenuDiv
{
display:none;
}

Step 3: Apply both Style Sheet on Page.

<html>
<head id=”head1″ RunAt=”Server”>
<title>Print Test Page</title>
<link href=”StyleSheet.css” rel=”Stylesheet” />
<link href=”Print.css” media=”print” rel=”Stylesheet” />
</head>
<body>
<form id=”form1″ RunAt=”Server”>
<table width=”100%”>
<tr>
<td colspan=”2″>
<div id=”headerDiv”>Header of the Page will display and Print</div>
<td>
<tr>
<tr>
<td>
<div id=”leftMenuDiv”>Left menu will display only, will not print on printer.
<a href=”?” onclick=”javascript:window.print();”>Print</a>
</div>
<td width=”100%”>
<div id=”rightContentDiv”>Right content page for display page contents</div>
<td>
<td>
<tr>
<tr>
<td colspan=”2″>
<div id=”headerDiv”>Footer of the Page will display and Print</div>
<td>
<tr>
</table>
</form>
</body>
</html>

for print the page, click on print link or File Menu->Print.

enjoy!

Advertisements