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 woul
The equivalent of content placeholders in Razor are sections.
In your _Layout.cshtml:
@RenderSection("Styles", required: false)
Then in your content page:
@section Styles {
}
An alternative solution would be to put your styles into ViewBag/ViewData:
In your _Layout.cshtml:
@foreach(string style in ViewBag.Styles ?? new string[0]) {
}
And in your content page:
@{
ViewBag.Styles = new[] { "~/Content/StandardSize.css" };
}
This works because the view page gets executed before the layout.