There are two kinds of CSS used to customize the print and screen look and feel of a web page.
The JavaScript function is used to print the current web page without any server code. The window. print() method is used to print the web page as it is. But if you want to print a portion of the web page then server-side code is needed to do the printing. However the media CSS is used to customize the printing of a page without any server-side logic.
<link href="Print.css" type="text/css" rel="stylesheet" media="print" />
The media has several types and print is the property that applies the CSS for printing the web page. You can write the CSS to customize the web page like font style, background color, foreground color, display and hide the content.
It will not affect the current web page display in the browser and when you take the printout and view the page in the print view then you can look at the media CSS effect.
Let's create the aspx page to display the list of names in the Grid.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="MediaCSS_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<link href="Print.css" type="text/css" rel="Stylesheet" media="print"/>
</head>
<body>
<form id="form1" runat="server">
<p>
<table width="100%">
<tr class="TrNotDisplay">
<td>
<h3>
CSS for Print out - Example Page</h3>
</td>
</tr>
<tr class="TrNotDisplay">
<td>
<a style="color: blue;" onclick="window.print();">Print</a>
</td>
</tr>
<tr>
<td>
<asp:GridView CssClass="GridStyle" ID="GridView1" runat="server">
</asp:GridView>
</td>
</tr>
<tr class="TrNotDisplay">
<td style="padding-top: 25px;">
Note:
<br/>
Take the print out unless until it is important<br/>
Save the trees
</td>
</tr>
</table>
</p>
</form>
</body>
</html>



kannanPosted Jan 4, 2019, 12:51 AM
Hi Senthil, Iam trying to print html page to dot matrix printer but its not clear,can you please tell me is there any possible solutions to print html/webpages to dot matrix printer.
Gowtham RajamanickamPosted Apr 14, 2016, 11:16 PM
nice article
htun lin aungPosted Sep 5, 2012, 9:27 PM
I am creating business card web site. In this site, i allow the customer to change their name and image on it.So how can i create the web page to allow customize and print the card.
Gaurav GuptaPosted Apr 26, 2012, 11:53 PM
Hi, Nice Article, Thanx for sharing..
Arjun PanwarPosted Apr 26, 2012, 11:51 PM
Hi...I want to know that how do I remove a line segment from a PathGeometry in wpf?
Arjun PanwarPosted Apr 26, 2012, 11:50 PM
Hi....I want to know that how to remove a line segment from a PathGeometry in wpf?
Lajapathy ArunPosted Apr 26, 2012, 3:25 PM
Thanks good one
Lajapathy ArunPosted Apr 26, 2012, 3:24 PM
this works in IE9 Compability?