Solved

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

Posted on 2013-05-17
4
1,383 Views
Last Modified: 2013-05-20
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
0
Comment
Question by:finance_teacher
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Stephan
ID: 39176982
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

0
 

Author Comment

by:finance_teacher
ID: 39177149
Can you provide a FULL example or webpage talking about this ?
0
 
LVL 16

Accepted Solution

by:
Stephan earned 500 total points
ID: 39177197
0
 

Author Comment

by:finance_teacher
ID: 39181488
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; }
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now