The name 'media' does not exist in the current context
The @
is a reserved character in Razor. But you can escape it using @@
:
@@media print
How can I specify CSS @media within a razor file?
You can use @@
which razor ignores and prints one @
.
PDFReactor .NET - @page is not exist is current context
Sorry guys.
I found the answer in this post :
"The name 'media' does not exist in the current context"
Basically it's due to the '@' symbol is actually a reserved character in Razor and we could escape it by using '@@'
Razor View throwing The name 'model' does not exist in the current context
I think you have messed up the web.config file which lives in the Views folder.
Create a new project targeting the same .NET framework and copy its Views/web.config file on top of the one in your current project. This will fix your problem.
Also, as Dudeman3000 commented, if you have Areas in your MVC project they all have Views\web.config
files too.
The name 'x' does not exist in the current context
ok, I figured it out. it's an Intellisense problem... in fact, in I just compile the code and run the application, everything is fine. I pulled a lot of hair over this!
@media rule in style tag in .cshtml file throws error
In .cshtml you can not use it as it is because it will be treated as a class or object. you need to put an extra @
whenever you need to add anything that starts with @
in an html file. Try using this
<style type="text/css">
.on-the-fly-behavior {
background-image: url('particular_ad.png');
}
@@media (max-width: 300px) {
.on-the-fly-behavior {
background-image: url('particular_ad_small.png');
}
}
</style>
C# Razor The name does not exist in the current context
In Razor when we want to write c# statements we have to tell it that from here c# code starts:
@{ // from here c# block starts
string testVar = "test";
} // here ends
Now if you want to access this variable in html you can do like this:
<span>@testVar</span>
When you are writing:
string prop = @p.Name + " (" + @p.PropertyType + ") - " + @p.GetValue(@page, null).ToString() + "\r\n";
it is considered as plain text and will be rendered on browser like "string prop = ..."
you have to tell that it is c# code by following way:
@{
string prop = @p.Name + " (" + @p.PropertyType + ") - " + @p.GetValue(@page, null).ToString() + "\r\n";
}
Namespace System.Media does not exit
System.Media
namespace is not available in UWP applications so you can't use SoundPlayer
. For playing sounds or other media you can use MediaElement
Related Topics
Display Two Object Same Real Distance (E.G. Inches) Apart Across Different Browers/Screen Sizes
HTML5 & Bootstrap Class="Container", Can It Be Applied to Body or Only Div
Why Don't We Have a // Comment in CSS
Br Line-Height in Safari and Chrome Leaving Gap
How to Print a Web Page with All Its CSS Style Attached to The Page
Difference Size Font Rendering on Windows Vs Macos. How to Solve
What Does Multiple Class Definition Mean and How Is It Supposed to Work
How to Use The Auto Value with The Calc() Property
Displaying an Element Similar to P Inside a Span
How to Apply Different CSS Styles to 2 Elements with The Same Class Name
Don't Change Link Color When a Link Is Clicked
How to Style The Input Type "Time"
Can The SASS Minifier Remove Duplicate Styles
Div at Bottom of Window and Adaptable Height Div
How to Fix Background Image Inside Div