user778194
user778194

Reputation: 41

Adding data on Print functionality in MVC3

I have a web page designed in MVC3. I want to add some data (a disclaimer text) at the bottom of the page on the print button click and then print the page. How to do this?

Thanks!

Upvotes: 4

Views: 850

Answers (2)

dknaack
dknaack

Reputation: 60438

Description

You can do this using css.

  • Create a div at the end of your page and give them a className disclaimer
  • Create a stylesheet file for the normal view of your page and set the display attribute to none
  • Create another css file called print.css and set the display attribute to visible

Sample

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title></title>
        <link href="myCSSfile.css" rel="stylesheet" type="text/css" media="screen">
        <link href="print.css" rel="stylesheet" type="text/css" media="print">
     <head>
    <body>

        <!--- your content --->

        <div class="disclaimer">Your disclaimer text</div>
    </body>
</html>

Your myCSSfile.css

.disclaimer { display: none; }

Your print.css

.disclaimer { display: block; }

More Information

Upvotes: 2

Chris Marisic
Chris Marisic

Reputation: 33098

You want to use CSS and print media style sheets to make the element visible for printing.

A basic tutorial about this can be seen here: CSS Media Types Create Print-Friendly Pages

Upvotes: 0

Related Questions