I need to render some script in the head section of an ASP.NET MVC view. How can this be achieved?
In ASP.NET we had ContentPlaceHolders in Master. What is the MVC equivalent of implementing this?
I need to render some script in the head section of an ASP.NET MVC view. How can this be achieved?
In ASP.NET we had ContentPlaceHolders in Master. What is the MVC equivalent of implementing this?
You can use @section
like this:
Master file:
@RenderSection("masterjs", required: false)
View file:
@section masterjs
{
<script type="text/javascript" src="@Url.Content("/Scripts/SomeScript.js")"></script>
}