Reputation: 6839
I have a razor master layout _Master.cshtml
and I include Master.css
in it.
I also have a Home.cshtml
and _Master.cshtml
is it's layout.
In home I have a view Event.cshtml
- this view does not have any master page setup.
@{
Layout = null;
}
<style>
.boxStyle{...}
</style>
<div class="boxStyle">
...
</div>
This works. But I want to move .boxStyle
to the Master.css
And when I move it there it doesn't work anymore.
But if I add bellow code to _Master.cshtml
then works. But I need it in css file.
<style>
.boxStyle{...}
</style>
What am I doing wrong here?
Upvotes: 0
Views: 2890
Reputation: 4458
Are you sure your Event.cshtml file has no master layout? If it is in it's own folder you can add a _ViewStart.cshtml file to that folder and add
@{
Layout = "~/Views/SomeFolder/_Master.cshtml";
}
to this file. (SomeFolder is the folder that Event.cshtml is in) Then you can add a new master layout _Master.cshtml with this in it:
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="/css/Master.css">
</HEAD>
<BODY>
@RenderBody()
</BODY>
</HTML>
Upvotes: 1
Reputation: 2496
If you move the css from the Event.cshtml
to the Master.css
you have to place a link tag in the Event.cshtml
like that.
<link rel="stylesheet" type="text/css" href="/css/Master.css">
Of course you need to add to the Event.cshtml also the basic html tags
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="/css/Master.css">
</HEAD>
<BODY>
..
</BODY>
</HTML>
Upvotes: 1