Reference jQuery correctly in ASP.NET MVC

This problem was detected: I'm ve created a new blank project of ASP.NET MVC site. Then Itrying to add a link to jquery-1.3.2.js from the main page. But in this case, the page doesn’t be t loading to browser. Itry and src = "<% = Url.Content (" ~ / Scripts / jquery-1.3.2.js ")%>", anyway. Then I moved the script link to the end and the page started loading. But I need to use jQuery before, in ContentPlaceHolders. What is the problem?

+3
source share
3 answers

You should be able to link to it at the beginning of the main page.

Did you try to just hardcode the original value?

<script src="/scripts/jquery-1.3.2.js" type="text/javascript"></script>

Of course, your path may be different ...

<script src="<%= Url.Content("~/scripts/jquery-1.3.2js") %>" type="text/javascript"></script> 

Should work though ...

+4

jquery google Microsoft cdn?

, .

+1

I think that based on an empty project, using the default project template for ASP.NET MVC, you need to do this:

src="<%=Url.Content ("~/Content/Scripts/jquery-1.3.2.js") %>"

All resources are placed in the Content folder by default, unless you change this, or I just remember it incorrectly.

In any case, when the page displays an html source check and finds out what the src attribute is being evaluated for, and make sure that it is correct. Once I had the same problem, and it turned out that it turned out.

0
source

Source: https://habr.com/ru/post/1718487/


All Articles