You must Sign In to post a response.
  • Category: .NET

    Moving all js functions into a single file and pass query strings to js function


    I am using javascript function in many pages of my project.
    Actually I have a requirement of moving all javascript function to a single file.
    So I have two question.

    1) How to place all javascript functions in a single file ?
    2) I am passing id in query string to that functions.
    So how to pass querystring values after placing the functions in a single file ?

    Thanks and Regards,
  • #652437
    follow the below steps
    1. copy all the js function in a .js file
    2. add a link tag in you .aspx file for binding .js & .aspx file
    3. if you are using master page then add link tag only in .master file
    4. And make all the js function parameterized

    If you follow the steps mentioned above. you might resolve your problem.

  • #652447

    You can place all the javascript method in a single file. And the single file can be across the page. You just have to link the JS file in all the page so that you can use all the method present inside the same. You can use the command like

    <script src="Folder/Filename.js" type="text/javascript"></script>

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #652966

    Thank you for you reply.
    And I have another problem like, I have a master page with multiple javascript link tag,
    when I am moving all those to a single js file and adding that file in master page I am getting script errors like,
    "Expression Expected".So how to resole this issue.
    Can you answer me asap?

    Thanks and Regards,

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.