1

Kinda related to my first question, my site runs fine locally but as soon as I deploy to IIS the javascript file/s are not being called properly.

In the <head> tag of my Master page:

<script src='/Assets/jquery-1.4.2.min.js' type="text/javascript"></script>
<script src='/Assets/hoverIntent.js' type="text/javascript"></script>
<script src='/Assets/superfish.js' type="text/javascript"></script>
<script src='/Assets/supersubs.js' type="text/javascript"></script>

This works on visual studio dev server but not on IIS. I tried adding ~ and saying runat="server" but it just gives some jquery error ("Unexpected character '\'" on Line 18 of the minified jquery) when trying to run it.

2
  • Is there a reason you can't just use a relative path? Commented Oct 6, 2011 at 13:44
  • Have you tried browsing to the paths above in your browser? the / at the start means you're defining absolute paths, so check they're still valid. eg yourhost/Assets/hoverIntent.js Commented Oct 6, 2011 at 14:01

1 Answer 1

1

Use Page.ResovleUrl for all of your files:

<script src='<%# Page.ResolveUrl("~/Assets/jquery-1.4.2.min.js")%>' type="text/javascript"></script>
Sign up to request clarification or add additional context in comments.

3 Comments

trying this i get an error "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."
using # and it simply doesn't work. not calling the js files. :/
Does your <Head> tag have runat="server"?

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.