Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-05-17
4
Medium Priority
?
1,605 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 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

704 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