Sponsored By
MindStick SurveyManager
Advertise with Us
Advertise with Us
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form

Home >> .Net >> C# >> css @media print not working
Author Post

jacob rasel

Total Post: 57
Member Since: 3/5/2013
Points: 289
css @media print not working
Posted On: 4/10/2013 2:08:38 AM
Hi Everyone!

I am trying to change style of printed document using css (@media print) and have defined a simple style to change the heading fontsize while printing. However the style for print media is not changed at all. Could anyone tell where I went wrong? Thanks! Here's what I did

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="testmediacss.aspx.cs" Inherits="PrintDemo1.testmediacss" %>
<!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 runat="server">
    <style type="text/css" >
   @media print { body {font: 50pt Arial;} h1 {font-size: 138pt;} h2 {font-size: 15pt; color: #000;} }
    <script type="text/javascript" language="javascript">
        function CallPrint(strid){
            var prtContent = document.getElementById(strid);
           var WinPrint = window.open('', '', 'letf=1000,top=1000,width=1000,height=500,toolbar=0,scrollbars=0,status=0');
    <form id="form1" runat="server">
    <div  id="divprint">
        <p>hello this is the part to be printed in the printer.</p>

        <h1>hello world</h1>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="CallPrint('divprint');" />


Thanks in advance! 
Author Post


Total Post: 605
Member Since: 5/2/2012
Points: 5841
Re: css @media print not working
Posted On: 4/15/2013 7:51:13 AM
Report Abuse Answer
Hi Jacob!

I have always used both media print and media screen when defining css.

@media print
  h1 {font-size: 138pt;}
@media screen
 h1 { font size: 95pt;}
It will show up on the screen as 95 point text, but print as the 138 point text.
Report Abuse Form
Total Online Users: 4859
MindStick DataConverter
Advertise with Us
Copyright © 2009 - 2014MindStick. All Rights Reserved.