I have a asp.net webforms 3.5 solution with multiple projects. In one of the (web) projects I have a script folder containing javascript files. In my aspxpage in project A I would like to call a js function residing in a js file called MyScript.js which sits in project B?
1 Answer
Include the JS file from project B like so:
<script src="http://myUrl.com/js/MyScript.js"></script>
Then just call the method you want.
4 Comments
user603007
ok, but what if I want to move myUrl.com to a different environment like production?
Abe Miessler
You will need to change it unless you can figure out some sort of relative URL that will work for your needs. I don't know what your dev/test/prod environments will look like for the projects so it's hard to give an exact answer.
user603007
suppose the script file sits in webproject called MyProjectB in a folder called 'Scripts'. What is the relavtive script reference then? How do I resolve the right reference even if I move MyProjectB to prod?
miahelf
Usually you will want to configure URLs with some server side variables that change from dev to production servers. For example, you could have a config.asp included, that defines the URLs in question. For the dev servers, the config.asp would have dev URLs, for the production servers, the config.asp would have production URLs. Then all you have to do is leave config.asp alone and include it, while editing the rest of your code to develop your site.