Search code examples
javascriptasp.netajaxasp.net-ajaxautocompleteextender

Ajax AutoCompleteExtender 's with javascript


I have to use Ajax AutoCompleteExtender multiple times in a web form where i m trying to set the AutoCompleteExtender list's width according to its contents width.

 function onListPopulated() {
var completionList = $find("AutoCompleteEx").get_completionList();
completionList.style.width = 'auto';
}

This method works fine with one behaviorID but when i try to use the same function n pass the AutoCompleteExtender ID in method so that only 1 method is used for all AutoCompleteExtenders , then nothing is happening. I tried to pass the ID as parameter but didnt worked. May be i am missing something.

Thanks in advance.


Solution

  • My question is solved using below code

    //In the AutoCompleteExtender 
    OnClientPopulated="onListPopulated"
    


    //and javascript 
     function onListPopulated(sender, e) {
         var completionList = sender.get_completionList();
          completionList.style.width = 'auto';
     }