Mayfield Global Knowledge Center



How do I add my custom Javascript files to ASP.NET AJAX enabled website?

  1. In your .aspx file add a script manager control with a reference to your javascript file:  <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="MyJavaScriptFile.js" />
        </Scripts>
    </asp:ScriptManager>

     If you are using master pages in ASP.NET 2.0, please review:
    I am utilizing master pages in my ASP.NET AJAX enabled web site. How do I load my custom JavaScript files when needed.

  2. ASP.NET AJAX ensures that all external JavaScript files have been properly loaded. In order to let ASP.NET AJAX know that the Javascript file has been loaded, the following code must be placed at the end of every .js file: if (typeof(Sys) != "undefined") {
        Sys.Application.notifyScriptLoaded();
    }

Would you like to...


del.icio.us

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favoritesAdd to favorites

User Opinions (28 votes)

85% thumbs up 14% thumbs down

How would you rate this answer?

Helpful
Not helpful
Thank you for rating this answer.