JavaScript Only works in roothttp://forums.asp.net/t/1799845.aspx/1?JavaScript+Only+works+in+rootFri, 04 May 2012 13:27:30 -040017998454964378http://forums.asp.net/p/1799845/4964378.aspx/1?JavaScript+Only+works+in+rootJavaScript Only works in root <pre class="prettyprint">Anyone know why this is?</pre> <pre class="prettyprint">This Works: &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"&gt; &lt;script src="../HourScripts.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/asp:Content&gt; This Does Not Work: &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"&gt; &lt;script src="../Scripts/HourScripts.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/asp:Content&gt;</pre> <p></p> 2012-05-03T19:30:40-04:004964478http://forums.asp.net/p/1799845/4964478.aspx/1?Re+JavaScript+Only+works+in+rootRe: JavaScript Only works in root <p>I have had issues with relative paths from master pages. What you must remember is that the urls are interpreted relative from your content page and not from your master page. Can you elaborate on your project organization and how your files are organized?</p> 2012-05-03T21:32:43-04:004964530http://forums.asp.net/p/1799845/4964530.aspx/1?Re+JavaScript+Only+works+in+rootRe: JavaScript Only works in root <p>The Scripts folder is just above the root, so project/Scripts. The folder where the page lives that calls the javascript function is also just above the root, so Project/Hours.</p> <p>Not positive I'm being helpful, but what do you think?</p> 2012-05-03T23:47:31-04:004965740http://forums.asp.net/p/1799845/4965740.aspx/1?Re+JavaScript+Only+works+in+rootRe: JavaScript Only works in root <p>Ok, that helps me understand your project structure. But based on that structurs I would think that your results would be reversed. One thing you can do to test the path that is being generated is to open a page in your browser, view the source, and find the script block. What path has been inserted there? Can you put that path in your browser and get to the script file? So if your page is at <a href="http://localhost:XXXX/MyProject/Pages/Page1.aspx">http://localhost:XXXX/MyProject/Pages/Page1.aspx</a> and the rendered script block is src=&quot;../scripts/script1.js&quot;, you should be able to build the full url as <a href="http://localhost:XXXX/MyProject/scripts/script1.js">http://localhost:XXXX/MyProject/scripts/script1.js</a>.</p> <p>Also, I have run into interesting caching issues in visual studio; especially with javascript files and css files. If you recently moved your script files, you could be running into caching problems. Clear your browser cache to see if that remedies the situation as well.</p> 2012-05-04T13:27:30-04:00