Change ServiceMethods and Web Service for the AutoCompleteExtender From Client Side

This is quite a common requirement and guess the Docs are not really clear as to how you can achieve this .

Lemme see how I can help

  1. You want to  change the Webmethod that the AutoComplete Extender Talks to from the Client Side.
  2. You want to  change the WebService that the AutoComplete Extender Talks to from the Client Side.

You can achieve this easily using the Functions Provided by the Extenders on the Client Side.

Follow these Simple Steps.

1) Assign a BehaviourID to the AutoCompleteExtender.

 

 <cc1:AutoCompleteExtender 
               ID="AutoCompleteImagesExtender1" runat="server" TargetControlID="myTextBox"
                ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="2"
                CompletionInterval="1000" EnableCaching="true" 
                CompletionListElementID="divCompletionImages"
                CompletionSetCount="12" 
                BehaviorID="autoCompleteExtender" >
</cc1:AutoCompleteExtender>
 2) You can change the Web Service that the AutoCompleteExtender Talks to by using the Following JavaScript.
  
 function ChangeServicePath(){
        var autoComplete = $find("autoCompleteExtender");
        autoComplete.set_servicePath( <NewServicePath>);
        }
  
 As you can see the $find  method is called on the behaviourID of the AutoCompleteExtender.
 The "set_servicePath" method allows you to Set the path to the Web Service that the Extender talks to .
 3) You can change the Web Service that the AutoCompleteExtender Talks to by using the Following JavaScript.
 function ChangeServiceMethod(){
        var autoComplete = $find("autoCompleteExtender");
        autoComplete.set_serviceMethod( <NewServiceMethodName>);
        }
  
 The "set_serviceMethod" method allows you to Set the path to the Web Service that the Extender talks to .
 Hope this Helps 
  

Comments

  • Anonymous
    February 15, 2007
    You've been kicked (a good thing) - Trackback from DotNetKicks.com

  • Anonymous
    February 15, 2007
    How would you handle the case where the extender is used in a templated databound control (e.g. Repeater)?

  • Anonymous
    February 15, 2007
    Good to see you in the blogging world!

  • Anonymous
    April 03, 2007
    Have you succeeded in using the $find function to get a reference of the extender? When I try to use it, autoComplete is still null. It doesn't seem to find it. Do I need to add any references or anything? Thanks

  • Anonymous
    April 03, 2007
    Hi Ilir, You should be able to get a handle to the Behavior of the ACE by using its Behavior ID , if it doesnt work , do you mind dropping me  a sample using the contact form ? I'll take a look at it and try to help out

  • Anonymous
    January 22, 2008
    Is it possible to attach one ACE to multiple Textbox controls on the page? I have a scenario where there are four fields on the page which call the same webservice and webmethod. Can I have just one ACE on the page for these controls and change the Target Control ID using Javascript? Thanks

  • Anonymous
    July 16, 2008
    Zolpidem and sleepwalking. Zolpidem eszopiclone indications. Zolpidem fedex. Zolpidem without prescription. Zolpidem.

  • Anonymous
    March 24, 2011
    The comment has been removed