ASP.NET and AJAX: So Freaking Easy (Part 3: Custom Scripts)
Recall (in my first post, see link above) how I mentioned you had to add a ScriptManager to your form in order for ASP.NET AJAX to function. Well, if you’re not adding your own scripts to the site, that’s all you need to do with it. However, if you would like to add your own scripts, doing so is ridiculously easy.
To add custom scripting, within your <asp:scriptmanager></asp:scriptmanager> tags, simply add the following:
<asp:scriptreference path=”~/scriptFolder/yourScript.js” />
You guessed it. That’s it.
Ok, not entirely it, but mostly. If you want, you can also add these two lines to your scripts to notify the client side ASP.NET AJAX framework when the script is finished loading:
if (typeof(Sys) !== ‘undefined’)
I’ve tried it without these lines and had no problem running my scripts, but if you are having problems, maybe adding these lines may help.