Search code examples
javascript.netajaxtoolkit

Ajax Toolkit CascadingDropDown onload event?


I would like to know if this is possible to create an JavaScript/jQuery event on Ajax Toolkit CascadingDropDon load.

Scenario:

I am selecting item on first dropdown -> second dropdown is loaded with Ajax Toolkit cascading dropdown feature -> as a reaction for this my JavaScript function fires.


Solution

  • Did it!

    Here's a method:

    In CascadinDropDown declaration I have added BehaviourID:

    <cc1:CascadingDropDown 
    ID="CascadingDDL" 
    TargetControlID="childDDL" 
    ParentControlID="parentDDL"
    Category="ddl"
    PromptText="Select"
    ServicePath="~/webmethods.asmx"  
    runat="server" **BehaviorID="cddBehaviourID"**
    ServiceMethod="GetValuesForDDL" Enabled="True">
    </cc1:CascadingDropDown>
    

    In script:

    function pageLoad(sender, args) {    //For Ajax toolkit to fire on 'window.onload'
    
          var behavior = $find('<%=CascadingDDL.BehaviurID %>');
    
          if (behavior != null) {
    
                behavior.add_populated(function() { *what you want to execute* });
    
          }
    }