Question

Normally, I can can set the TargetControlID server side using something like this:

    AutoCompleteExtender ace = new AutoCompleteExtender();
    ace.ID = "AutoCompleteExtender1";
    ace.TargetControlID = "whatever";

I know how to grab the AutoCompleteExtender client side, but I am looking for a method to update the TargetControlID client side too. Any ideas?

Was it helpful?

Solution 2

Apparently Microsoft didn't think was important, so there is not a way to do this at this time :)

OTHER TIPS

Well sadly this is not possible for existing instance of AutoCompleteExtender. There are a few methods that you might be interested in like below

var x = $find("AutocompleteBehaviorID");//find the instance

x.get_completionListElementID();//get the ID of target textbox

x.set_completionListElementID();//set the ID of target textbox has no effect though :(

x._completionListElement();//direct access to DOM element that acts as target

the problem here seems initialized version attaches additional events to target textbox during init phase of the control toolkit( yeah client side too has a init phase). When a initialized version is made to change as the target (as you wanted to do) then these events keypress,blur etc are not added hence you don't see any changes. But if you knew javascript you can do the below to make it work with any textbox.

$create(Behavior,{properties},{events},interfaces,target);

where

Behavior

AjaxControlToolkit.AutoCompleteBehavior

properties

is a javascript object as below (there are more properties but these suffice

{
    "completionInterval": 1,
    "completionListElementID": "empty panel id",
    "completionListItemCssClass": "css class name",
    "delimiterCharacters": ";",
    "highlightedItemCssClass": "css class name",
    "id": "CLIENTSIDEID",
    "minimumPrefixLength": 1,
    "serviceMethod": "WebMethodName",
    "servicePath": "AbsolutePath to asmx file"
}

Events

there are more events available

{
    "itemSelected": jsFn,
    "populated": jsFn
}

The Target

Target element is the most important. It is this text box that all the events ,bells and whistles attracted to.

$get("ELEMENT ID")

now that is all over , you can initialize a instance of auto complete though javascript all the time. Just make sure the ID already does not exist.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top