Solved

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

Posted on 2013-05-17
4
1,530 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 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