0

I am required to create a print friendly Page containing just a few data fields from my one-page website. I have been told to do this by using Response.Write.

I was given this clue in my task:

The trick is to use the Response method, which is provided by the Page Class (more precisely, it is provided by a parent class named System.Web). What you show on the screen is managed by the System.Web object and using the Response method you can put anything you want in there.

I've done some Googling but this doesn't seem like the way this should be done, however for some reason it must be done this way.

Basically it must create a print-friendly page by clearing the page and passing through only some variables to display plain black on white.

il_guru
  • 8,383
  • 2
  • 42
  • 51
Rothmanberger
  • 177
  • 2
  • 11

1 Answers1

1

I have been told to do this by using Response.Write.

Whoever told you to do it this way is wrong, wrong, wrong.

If you need to make any kind of web page "printer friendly", then the right way to do it is via media queries

So if your page currently has CSS like this

<link rel="stylesheet" type="text/css" href="style.css">

Then you simply create a second style sheet that does everything you need to make your page "printer friendly, and then change your html to include the print version.

<link rel="stylesheet" type="text/css" media="print" href="print.css">
<link rel="stylesheet" type="text/css" media="screen" href="style.css">

Then in your print.css stylesheet, you can use styles that are directly related to a print view. Some examples can be found in this link

/*Make your layout similar to a sheet of paper*/
body, #content, #container {
    width: 100%;
    margin: 0;
    float: none;
    background: #fff url(none);
}

/*Hide navigation, ads, and anything else you don't want printed*/
#topnav, #navbar, #nav, #sidebar, .ad, .noprint {
    display: none; 
}

/*Set a new default font*/
body {
    font: 1em Georgia, "Times New Roman", Times, serif;
    color: #000; 
}

/*Style your headings*/
h1,h2,h3,h4,h5,h6 {
    font-family: Helvetica, Arial, sans-serif;
    color: #000;
}
h1 { font-size: 250%; }
h2 { font-size: 175%; }
h3 { font-size: 135%; }
h4 { font-size: 100%; font-variant: small-caps; }
h5 { font-size: 100%; }
h6 { font-size: 90%; font-style: italic; }

/*Display the links associated with hyperlinks*/
a:link, a:visited {
    color: #00c;
    font-weight: bold;
    text-decoration: underline; }

#content a:link:after, #content a:visited:after {
    content: " (" attr(href) ") ";
}
Chase Florell
  • 46,378
  • 57
  • 186
  • 376