Pergunta

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.

Foi útil?

Solução 2

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';
 }

Outras dicas

If you are structuring the method like this:

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

That is correct; make sure you are passing the ID in as so:

onListPopulated("<%= AutoCompleteEx.ClientID %>");

Using the ClientID ensures the correct ID is used.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top