0

From some previous posts I have done something like this to use @scripts.render( /bundles/jqueryval ) in my partial view.

LayoutUser.cshtml (Master layout)

@RenderSection("Script", false)
@section Script{
<script src=..... </script>
......
}

AccountLogin.cshtml(Partial layout)

@section Script {
@Scripts.Render("~/bundles/jqueryval")
}
<script src=..... </script>

This portion of implementation works fine for AccountLogin.cshtml page but unfortunately my master layout script not working. As I am newbie to MVC, its really hard to understand the actual cause and solution of this. Am I use @scripts.render( /bundles/jqueryval ) correctly to the partial view or just need to change master layout script section? Thanks

FaHaD
  • 93
  • 1
  • 3
  • 13
  • Possible duplicate of [Using sections in Editor/Display templates](http://stackoverflow.com/questions/5433531/using-sections-in-editor-display-templates) – trailmax Feb 27 '17 at 19:31

1 Answers1

-1

You can't define a section in a partial. You can simply include the script itself; you just can't make it go into that section in your layout. However, depending on how you're using this partial, even that may not work. If you're pulling it in via AJAX, any script tags will be ignored.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444