Link to home
Create AccountLog in
Avatar of finance_teacher
finance_teacher

asked on

ASP.Net MVC 4 C# -- print only @RenderBody() content ?

How can I do something like the below "site-wide" ?

Steps
 1. user opens webpage
 2. clicks "Printer" ICON on any page
 3. only the \Views\Shared\_Layout.cshtml @RenderBody() content prints,
    none of the other header/footer details print
Avatar of Stephan
Stephan
Flag of Netherlands image

The most easy way to do this, is simply use a CSS for printing. I also think this is the best approach because you don't have to do anything spiffy on your application.

use the following media query and place the css inside this block:

For example:
@media print
{
    header { display: none; }
}

Open in new window

Avatar of finance_teacher
finance_teacher

ASKER

Can you provide a FULL example or webpage talking about this ?
ASKER CERTIFIED SOLUTION
Avatar of Stephan
Stephan
Flag of Netherlands image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
The below work, I just needed to make sure IE did not cache my CSS each time.

@media print
{
    header { display: none; }
}

@media print
{
    h1, h2, h3 { display: none; }
}