Reputation: 187
I render section in HEAD od HTML page and PartialView in the middle of the page like the code shows below
<html>
<head>
@RenderSection("Scripts", false)
</head>
.....
@Html.Partial("_MenuAdmin")
</html>
In PartialView _MenuAdmin I have some javascript.
@section Scripts
{
<script type="text/javascript">
alert("Test");
</script>
}
So, the problem is that same JavaScript code doesn't loaded. If instead PartialView I use View JavaScript loaded properly.
How I can load JavaScript in my sample?
Upvotes: 1
Views: 861
Reputation: 9519
@section
is not supported inside a Partial View, you should use @Scripts.Render
directly in your view.
Upvotes: 1