I want to link a specific style sheet in certain Views in addition to what already gets linked in _Layout.cshtml. For non-Razor, I see using the content place holder. How would I do this for Razor?
相关问题
- Entity Framework throws exception - Network Relate
- Slow loading first page - ASP.NET MVC
- PHP Adding stylesheets to header
- TextBoxFor decimal
- How to include a safari only style in scss ? [dupl
相关文章
- “Dynamic operations can only be performed in homog
- Change color of bars depending on value in Highcha
- How to get server path of physical path ?
- Breakpoint in ASP.NET MVC Razor view will not be h
- How to define function that returns html in asp.ne
- How to find the exceptions / errors when TryUpdate
- ASP.Net MVC 3: optgroup support in Html.DropDownLi
- A circular reference was detected while serializin
The equivalent of content placeholders in Razor are sections.
In your _Layout.cshtml:
Then in your content page:
An alternative solution would be to put your styles into ViewBag/ViewData:
In your _Layout.cshtml:
And in your content page:
This works because the view page gets executed before the layout.
Surprisingly (to me), asp:ContentPlaceHolder does work. Seems very unrazorish though. I wonder if there's another way?
Specifically, you put
<asp:ContentPlaceHolder ID="HeadContent" runat="server" />
in your _layout.cshtml andin your view.