4

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?

3
  • Whats the error message? "Doesn't loading to browser" means a lot of things. Commented Sep 24, 2009 at 19:31
  • No error message. Web development helper shows, that all HTML has been transfered in responce, but the page stops rendering in place, where I put the reference to jQuery Commented Sep 24, 2009 at 19:36
  • 1
    Im very very sorry! Im an idiot. I`ve typed <script blah.. /> instead of <script blah.. ></script> Commented Sep 24, 2009 at 19:42

3 Answers 3

5

You should be able to insert it into 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.2.js") %>" type="text/javascript"></script> 

Should work though...

Sign up to request clarification or add additional context in comments.

3 Comments

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.
Im very very sorry! Im an idiot. I`ve typed <script blah.. /> instead of <script blah.. ></script>
After my mistake, your solution looks most colose to be right
1

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.

2 Comments

@jfar it's better for performance unless you happen to deploy to a cdn yourself. quicker for browser to download if not already cached
this site is used in Intranet
0

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.

1 Comment

There is a Scripts folder in blank project. I`ve been trying to use Url.Content, but all the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.