views:

169

answers:

3

Encountered such problem: Ive created a new blank project of ASP.NET MVC site. Then Im trying to add a reference to jquery-1.3.2.js from Masterpage head. But in this case, page doesnt loading to browser. Ive bee trying and src="<%=Url.Content ("~/Scripts/jquery-1.3.2.js") %>", all the same. Then I moved the script reference to the end of the , and the page began to load. But i need to use jQuery earlier, in ContentPlaceHolders. What is the problem?

+1  A: 

Why not reference teh jquery on the google or Microsoft cdn ?

From you master page is a good place to do this, correct syntax in links.

dove
How is this helpful?
jfar
@jfar it's better for performance unless you happen to deploy to a cdn yourself. quicker for browser to download if not already cached
dove
this site is used in Intranet
Alkersan
@Alklersan, fair enough.
dove
A: 

I think based on the way a blank project is made using the default project template for ASP.NET MVC you'd need it to do this:

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

All resources are put in the Content folder by default, unless you've changed that or I'm just remembering incorrectly.

Either way, when the page renders check the html source and see what the src attribute gets evaluated to, and make sure that's correct. I had the same problem once and that's what it turned out to be.

Joseph
There is a Scripts folder in blank project. I`ve been trying to use Url.Content, but all the same.
Alkersan
+2  A: 

You should be able to in the head of the master page reference it.

have you tried just hard coding the source 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...

klabranche
nothing. all the same
Alkersan
interesting....
klabranche
can you reference any javascript in that folder.... Experiment. Create a small js file with say an alert function and see if the code can reference it and does the same or works. If it works, I would maybe re-download jquery.
klabranche
I`m very very sorry! I`m an idiot. I`ve typed <script blah.. /> instead of <script blah.. ></script>
Alkersan
After my mistake, your solution looks most colose to be right
Alkersan
Glad you figured it out. :)
klabranche