Welcome to AspAdvice Sign in | Join | Help

Alessandro Gallo

.NET & Beyond
Loading custom JavaScript files through the ScriptManager

This is an important change from beta1. In the new beta2 release, scripts added through the ScriptManager using ScriptReference controls are loaded asynchronously by a script loader (Sys.ScriptLoader).

For this reason, every JavaScript file referenced using a ScriptReference control must contain a call, at the end of the file, that notifies Sys.Application when the script is loaded. The statement to add at the end of the JavaScript file is the following:

if(Sys && Sys.Application) {
    Sys.Application.notifyScriptLoaded();
}

 

 

If you omit the call to notifyScriptLoaded(), you may get a Sys.ScriptLoadFailedException.

As a consequence, all the JavaScript files that don't contain the above statement must be referenced outside the ScriptManager control.

Check also this blog entry by Luis Abreu for some details on this change.

Posted: Wednesday, November 08, 2006 1:29 AM by Garbin

Comments

Keyler said:

Microsoft Ajax beta 2 的一个重要改变(必看),Sys.ScriptLoadFailedException出现的一个原因,还有Collection类型的一个改进。

# November 9, 2006 9:19 PM

lodzio said:

# March 8, 2007 8:52 AM

Google排名 said:

Good ! thank the author.

# April 23, 2007 4:52 AM
New Comments to this post are disabled