Page view counter

Some Useful Information on Including Multiple Dependent Atlas Scripts

Last post 12-08-2006 12:35 AM by GQAdonis. 0 replies.

Sort Posts:

  • Some Useful Information on Including Multiple Dependent Atlas Scripts

    12-08-2006, 12:35 AM
    • Loading...
    • GQAdonis
    • Joined on 02-02-2006, 2:28 PM
    • Dallas, TX
    • Posts 110

    Many have read my "gripes" and "confusion" regarding the queued script loading features, and problems recognizing Javascript types when multiple dependent scripts with a complex Javascript "object inheritance" structure.  I have some new information regarding all this that might help others.

    Luis Abreu gave me the initial answer to the problem (many thanks to him for taking the time to look at it), although after I attempted to use the solution in my larger project as opposed to the sample I had provided, I still had problems.  These problems resulted from the fact that I was using the Atlas Control Toolkit as well as my own IScriptControl derived controls.  This is important, because script behaviors and custom script controls provided by the toolkit all derive from their implementation of ScriptControl, a base class that does two things relvant to this issue:

    1. Provides a nice base class implementation of IScriptControl that uses attributes to determine script dependencies and generate ScriptReference enumerators. This allows for an entire C# web control inheritance tree to have all marked dependent scripts included.
    2. During the script referencing process, the ScriptControl automatically generates the necessary Sys.Application.notifyScriptLoaded() blurb that is required for ScriptManager loaded scripts that end up on the queue. This means that it is not necessary to add that line to behavior or control script files derived from AjaxControlToolkit.ScriptControl.

    This becomes interesting when both ScriptControl derived controls and behaviors AND custom IScriptControl derived controls (some of which inherited from standard web controls like TextBox, Label, etc.) include common scripts in their inheritance trees. This ended up being the source of my problem in my larger project, since I either ended up with duplicate entries in the script references collection or had Sys.Application.notifyScriptLoaded() called too many times or both. The key, it has turned out, is that one must pick a single script dependency inclusion method and stick with it. Choosing the Ajax Control Toolkit's method for controlling script dependencies requires that all controls derive from ScriptControl, but it seems worth it to do so.

    What I have done is provide a common script "kernel" file that contains the definitions for objects that absolutely must be common for everything and add it to the ScriptManager's scripts collection. This file is not referenced anywhere else via IScriptControl implementations OR via attributes. It is just assumed by everything I use to just be there--hopefully.

    This completely eliminated my problem, and I will never again gripe about the queued script loading feature as any kind of issue. It does indeed work as designed if I do the right thing! I hope this might have helped someone else experiencing similar issues.

    I love Atlas again!

Page 1 of 1 (1 items)
Microsoft Communities