1

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?

0

1 Answer 1

2

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.

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

4 Comments

ok, but what if I want to move myUrl.com to a different environment like production?
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.
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?
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.

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.