4

I'm working on an .cshtml page that requires some basic inline styling for print only. I was going to use the @media print media query, however, this being an cshtml page, it breaks my page. Is there any way to get around this?

It's the @ symbol in @media print that is breaking it.

p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
Mark
  • 4,773
  • 8
  • 53
  • 91

2 Answers2

19

You can double the @ if you want to print a literal @ character in the output.

<style>
    @@media print {
       ...
    }
</style>
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
2

p.s.w.g is absolutely correct. To understand why the @ symbol is causing an issue in your .cshtml file I suggest you research Razor View Engine http://en.wikipedia.org/wiki/ASP.NET_Razor_view_engine which happens to start when you type @ in your .cshtml page. Simply put it's an HTML rendering mechanism that generates HTML for you. It is usually used when you want to display data contained in your models =]

hae
  • 216
  • 2
  • 4