Javascript and Root Relative Paths
OK, there turn out to be a number of ways to incorporate javascripts. One that does NOT work, I was already familiar with. In ASP.NET the runat="server" and use a ~ trick which is basically how I'm hooking up the CSS, does not work for Javascript. I ran across enough information when dealing with the css <link> tags that I knew it was not a viable option. It simply makes the server think the tag is running a server side script. Ooo... that's bad.
There were three recommendations I got on Javascripts. One was to use a ScriptManager object to incorporate the javascript; the guy who recommended it uses it routinely for his AJAX which is cool. This might be something to look into, but I'm not really up to any kind of speed on AJAX yet, so that's probably more fire power than I need right now. Another guy recommended using a RegisterClientScript object. I spent enough time studying it to figure out how to piece together a RegisterClientScriptInclude to incorporate my js file neatly. However, I don't know if this allows any control over where the script tag is written into page, my Javascript is programmed unobtrusively and has to come at the end of the file right before the </body> tag.
Another guy said that a leading slash, /, turns a relative reference into an application root relative reference (much like a ~). I believe I had tried this working with the CSS so I was not very kosher on it. But then... I tried a LOT of stuff to get the CSS up and running and I don't have a very good handle on what I did and didn't test and what else was going on with the files at the time. Since the / was the simplest recommendation I got, I tried it first.
I first tried throwing a leading slash in front of the relative link, ie src="/Scripts/earthchronicle.js". However, when I uploaded it, it didn't work. I was about ready to go looking for the syntax on the RegisterClientScriptInclude when I realized that the Scripts folder was not actually in the application root so even if the leading slash was working, my syntax wouldn't. I revamped the script source to src="/ECBeta/Scripts/earthchronicle.js" and voila! Everything javascript based started working. The leading slash method seems to work fine and until it breaks somewhere, I'm going to run with it.
Skip to Main Points