locked
javascript in separate asp.net file RRS feed

  • Question

  • User-1997257017 posted

    In a web form 2010 application, I have one  javascript function in an default.aspx to call another javascript file in a separate aspx file that is used in the _master.master page file. I would like the first javascript file to access the second javascript file. Thus can you tell me if this is possible? If you, can you show me the code on how to accomplish this goal?

    Saturday, August 20, 2016 8:33 PM

Answers

  • User475983607 posted

    In a web form 2010 application, I have one  javascript function in an default.aspx to call another javascript file in a separate aspx file that is used in the _master.master page file. I would like the first javascript file to access the second javascript file. Thus can you tell me if this is possible? If you, can you show me the code on how to accomplish this goal?

    Sure it is possible and very common.  Simply use a standard JavaScript file reference for each JS file you want included in the current page request.

    <script src="/scripts/first.js"></script>
    <script src="/scripts/second.js"></script>

    The browser simply load the code in order.  Variable and function scope is dependent on how you wrote the code.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 21, 2016 12:45 PM

All replies

  • User475983607 posted

    In a web form 2010 application, I have one  javascript function in an default.aspx to call another javascript file in a separate aspx file that is used in the _master.master page file. I would like the first javascript file to access the second javascript file. Thus can you tell me if this is possible? If you, can you show me the code on how to accomplish this goal?

    Sure it is possible and very common.  Simply use a standard JavaScript file reference for each JS file you want included in the current page request.

    <script src="/scripts/first.js"></script>
    <script src="/scripts/second.js"></script>

    The browser simply load the code in order.  Variable and function scope is dependent on how you wrote the code.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 21, 2016 12:45 PM
  • User-1997257017 posted

    Can you give me more reference for your statement, "Variable and function scope is dependent on how you wrote the code.  "? How do you keep JavaScript code within scope range? I am new to working with JavaScript.

    Monday, August 22, 2016 6:12 PM