Welcome to AspAdvice Sign in | Join | Help

Alessandro Gallo

.NET & Beyond
Tip: Using the Toolkit's Animation framework without the AnimationExtender

The Ajax Control Toolkit provides a powerful framework for creating animations, which consists of a set of classes contained in the client AjaxControlToolkit.Animation namespace.

The Animations.js file, which contains the definitions of all the animation classes, is loaded at runtime by the AnimationExtender (or the UpdatePanelAnimationExtender) together with other script files from which it depends.

If we want to take advantage of the Toolkit's Animation framework even without relying on an Extender, we have to add the following script references through the ScriptManager control:

 

<asp:ScriptManager id="TheScriptManager" runat=”server”>
<Scripts>
    <asp:ScriptReference Assembly="AjaxControlToolkit"
                Name="AjaxControlToolkit.Common.Common.js" />
    <asp:ScriptReference Assembly="AjaxControlToolkit"
                Name="AjaxControlToolkit.Compat.Timer.Timer.js" />
    <asp:ScriptReference Assembly="AjaxControlToolkit"
                Name="AjaxControlToolkit.Animation.Animations.js" />
</Scripts>
</asp:ScriptManager>

 

And if we're developing an Extender or a Script Control that makes use of the Animation framework, we can decorate the server class with the following RequiredScript attribute in order to have the Animations script file and all its dependencies automatically loaded at runtime:

 

[RequiredScript(typeof(AnimationScripts)]

 

The AnimationScripts type is contained in the AjaxControlToolkit namespace, inside the AjaxControlToolkit assembly.

Sponsor
Posted: Thursday, February 15, 2007 1:40 PM by Garbin

Comments

Tee+ said:

By adding those JS scripts through the ScriptManager control, is that really work ? If yes, why don't we need to add "

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();" at the bottom of those scripts ???

# February 15, 2007 4:28 PM

Garbin said:

Tee+: in ASP.NET AJAX 1.0 the script files are no more loaded asynchronously. Therefore there's no more need for the notification statement, unless the script files are added during a partial postback through the RegisterXXX methods of the ScriptManager.

# February 15, 2007 5:12 PM

Christopher Steen said:

ASP.NET Tip - Use The Label Control Correctly [Via: Haacked ] Exiting The Zone of Pain - Static Analysis...

# February 17, 2007 11:35 PM

fantomas said:

Thank you for the invaluable tip that saved me from 10-day struggling with this nasty error:

"'AJAXControlToolkit' is undefined."

I tried all the approaches recommended on the Internet -- none worked. Your tip turned out to be the best because it has fixed the very core of this problem.

I am using the AJAX 3.5 TextBoxWatermark Extender bound to  several InsertItemTemplate texboxes on the FormView in ASP 2.0.

Thanks again.

# January 25, 2008 5:51 PM

alex grach said:

hey, thanks for the tip. def helps out. also, saw your book at the store and i am going to go and purchase it. thanks for the info.

# January 30, 2008 6:52 PM
New Comments to this post are disabled