In my ASP.NET MVC3 project, I have the standard _Layout.cshtml generated by Visual Studio 2010, and after closing my <body> I put a RenderSection :
_Layout.cshtml:
</body> <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script> @RenderSection("ScriptContent", required: false) </html>
Then in my Index.cshtml View I have:
@model MyApp.ViewModels.MyViewModel @{ Html.RenderPartial("MyPartial", Model); }
If I put @section ScriptContent in Index.cshtml, it will display correctly. If I put it in my Partial View MyPartial.cshtml :
@model MyApp.ViewModels.MyViewModel @section ScriptContent { <script src="@Url.Content("~/Scripts/Filters.js")" type="text/javascript"></script> }
In my page source, I have:
</body> <script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script> </html>
The @section value @section not executed. What could be the reason? Thanks
asp.net-mvc asp.net-mvc-3 partial-views
Cicciomiami
source share