ASP.NET MVC Archives - 峰哥分享 https://www.dengnz.com/tag/asp-net-mvc/ 昨天,今天,明天,每天的每天,都多懂一点点... Tue, 14 Aug 2018 22:59:47 +0000 zh-CN hourly 1 https://wordpress.org/?v=6.5.4 https://www.dengnz.com/wp-content/uploads/2020/02/cropped-logo-32x32.png ASP.NET MVC Archives - 峰哥分享 https://www.dengnz.com/tag/asp-net-mvc/ 32 32 ASP.NET MVC Uncaught ReferenceError: $ is not defined https://www.dengnz.com/2018/08/14/asp-net-mvc-uncaught-referenceerror-is-not-defined/ https://www.dengnz.com/2018/08/14/asp-net-mvc-uncaught-referenceerror-is-not-defined/?noamp=mobile#respond Tue, 14 Aug 2018 22:50:13 +0000 http://www.dengnz.com/?p=1005 When a ASP.NET MVC project is created in Visual Studio … 阅读更多 »ASP.NET MVC Uncaught ReferenceError: $ is not defined

The post ASP.NET MVC Uncaught ReferenceError: $ is not defined appeared first on 峰哥分享.

]]>
When a ASP.NET MVC project is created in Visual Studio 2017, Jquery is
built in. But when you try to use jQuery in the index.cshtml file, you will
get the following error:

The wield thing here is that Visual studio’s template imports jquery script
after @RenderBody(). The code you write in index.cshtml is rendered by
@RenderBody
(). But as this happen before jQuery is imported, you get the $
is not defined error.

To fix this issue, you will have to move this code into the head section.

 

Note that, .NET MVC doesn’t have jQuery UI by default, if you want to use

any jQuery UI function, don’t forget to import jQuery UI.

The following example use jQuery UI from jQuery CDN.

The post ASP.NET MVC Uncaught ReferenceError: $ is not defined appeared first on 峰哥分享.

]]>
https://www.dengnz.com/2018/08/14/asp-net-mvc-uncaught-referenceerror-is-not-defined/feed/ 0