title: Printing with css style
body: <p>I have a css stylesheet linked to my webpage. When I view the webpage it look how it is supposed to look, but when I print the document I don't see the style anymore. I've added the css a second time with the attribute: <code>media='print'</code> but it won't work. Does anybody know how to use the <code>window.print()</code> function and keeping the style to the printing document?</p>
  
  <p>ASPX:</p>
  
  <pre><code>&lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="cpHead" ClientIDMode="AutoID"&gt;
  &lt;link rel="stylesheet" type="text/css" media="screen" href="Styles/Site.css" /&gt;
  &lt;link rel="stylesheet" type="text/css" media="print" href="Styles/Site.css" /&gt;
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="Main" ClientIDMode="AutoID"&gt;
      &lt;asp:Image ID="imgHeader" Width="100%" runat="server" /&gt;
      &lt;asp:GridView ID="gvPrintData" Width="100%" runat="server" HeaderStyle-CssClass="printGridHeader" RowStyle-CssClass="printGridRow" AlternatingRowStyle-CssClass="printGridAltRow" /&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>.CS:</p>
  
  <pre><code>Response.Write("&lt;script type='text/javascript'&gt;window.print(); window.onfocus = function() { window.close(); }&lt;/script&gt;");
  </code></pre>
  
  <p>Pageview (how it should look):
  <img src="https://i.stack.imgur.com/hVMW8.png" alt="Page"></p>
  
  <p>Printedview (how it looks on the printed document):
  <img src="https://i.stack.imgur.com/MwL68.png" alt="Doc"></p>