How to insert jQuery code? Uncaught ReferenceError: $ is not defined in view razor code

前端 未结 5 1928
执念已碎
执念已碎 2020-12-31 06:54

I have the following Asp.Net MVC 4 razor code at the end of the file.

....
@section Scripts {
    @Scripts.Render(\"~/bundles/jqueryval\")
}



        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 07:10

    No need to move anything. Just where you have the script in the view put the script inside a section scripts like so assuming you declared a section scripts in _Layout file:

    @section scripts{
        
    }
    

    you can do same technique for a section with additional CSS on each page, declare section CSS or Head or whatever name then add @section name{ } at the top of the view before the markup

提交回复
热议问题