Solved

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

Posted on 2013-05-17
4
1,353 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

13 Experts available now in Live!

Get 1:1 Help Now