0

Well i think razor views are only in MVC so we can only use these selections scripts in mvc only .. But why we use @section Scripts & @Scripts.Render .. is we use with jQuery. Are we only supposed to use them in MVC Views not in a simple HTML Page or with JSON only?

**@section Scripts {
  @Scripts.Render("~/bundles/jqueryval")
}**
  • 1
    Its not related to jQuery. Its razer syntax https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-2.2 – Webbanditten Jul 04 '19 at 08:44
  • 1
    This has nothing to do with javascript, it's a Razor statement to locate code within your Layout. – freedomn-m Jul 04 '19 at 08:44
  • 1
    This has nothing to do with jQuery, it has to do with Microsoft ASP.NET MVC. It allows a page to define a section that is rendered outside of the page in the layout file. – Fred Jul 04 '19 at 08:45
  • @Webbanditten So, its mean the views , in which its included will call a razor view and to embed js code in view we write this.? – Anam Azam Khan Jul 04 '19 at 08:49
  • Read the docs. Provided. – Webbanditten Jul 04 '19 at 08:53
  • 1. add a section to your _layout 2. in your view define an `@section` which will be rendered at the location of the section in your _layout. Any more is too much for a 1-liner summary which is all you can get here. You have the docs link and an SO answer to read up on. – freedomn-m Jul 04 '19 at 09:11

0 Answers0