locked
Javascript/JQuery after ajaxToolkit:CascadingDropDown populates RRS feed

  • Question

  • User-802912837 posted

    I have a page with an updatepanel that contains two ajaxToolkit:CascadingDropDown controls.
    I am trying to populate them after the page loads using javascript and/or JQuery. However, with all of the methods I've tried the javascript runs before cascadingdropdown controls have rendered. It finds the initial dropdownlist controls just fine, but the cascadingdropdown controls return null.
    I know the javascript function I'm calling is good, because it works if I make a button on the page call my function from there. So, it seems like the function is firing too early.
    I've tried to fire it using window.load, document.ready, by registering a client startup script in my code behind, and by just calling the function in script tags located at the bottom of my aspx page. I've also tried adding a two second delay at the start of the function by waiting for the clock to reach now plus two seconds.


    To summarize:
    My function works, but is just not being called at the correct time. Where and when do I need to call it for the page to truly be finished loading all my controls?
    Thanks,
    JTok

    Tuesday, January 29, 2013 5:23 PM

Answers

  • User555306248 posted
      function pageLoad(sender, args)
         {
             var cdd = $find("behaviorIDofCDD");
             cdd.add_populated(onPopulated);
         }
         function onPopulated()
         {
             //any function to be called
         

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 29, 2013 10:41 PM
  • User-802912837 posted

    Thank you! That didn't work for me exactly as it is. For some reason the onPopulated event wasn't firing.

    However, by calling my initial function in pageLoad and having it find the behavior IDs instead, everything worked.

    For the sake of future readers, I would also like to note that since pageLoad fires with any kind of postback, I put a boolean variable outsite the pageLoad function to check whether or not the code had been run yet or not like so:

    var done = false;
    function pageLoad(sender, args) {
        if (!done) {
            myFunction();
            done = true;
        }
    }



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 30, 2013 2:14 PM

All replies

  • User555306248 posted
      function pageLoad(sender, args)
         {
             var cdd = $find("behaviorIDofCDD");
             cdd.add_populated(onPopulated);
         }
         function onPopulated()
         {
             //any function to be called
         

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 29, 2013 10:41 PM
  • User-802912837 posted

    Thank you! That didn't work for me exactly as it is. For some reason the onPopulated event wasn't firing.

    However, by calling my initial function in pageLoad and having it find the behavior IDs instead, everything worked.

    For the sake of future readers, I would also like to note that since pageLoad fires with any kind of postback, I put a boolean variable outsite the pageLoad function to check whether or not the code had been run yet or not like so:

    var done = false;
    function pageLoad(sender, args) {
        if (!done) {
            myFunction();
            done = true;
        }
    }



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 30, 2013 2:14 PM