Adding Print Function Data to MVC3

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

Thanks!

+4
source share
2 answers

Description

You can do this using css.

  • Create a div at the end of your page and give them a class name disclaimer
  • Create a stylesheet file for a 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

Example

 <!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; } 

Additional Information

+2
source

You want to use CSS and print stylesheets to make the element visible for printing. A.

The following is a basic tutorial: CSS Media Types Create Printable Pages

0
source

Source: https://habr.com/ru/post/1388466/


All Articles