Emmanuel Medina
Emmanuel Medina

Reputation: 173

AjaxControlToolkit Autocomplete: How to use values automatically and do something when a value is selected

I have a couple of AutocompleteExtenders in some pages, now I want to do 2 things with them:

  1. If the extender only returns one value, use it automatically (put that string in the textbox)
  2. Once an item has been selected, put part of the string in another textbox

I was checking out the AutocompleteExtender reference, and found two properties of interest: OnClientItemSelected and OnClientShown but don't know how to accomplish what I want (above) with these.

Upvotes: 0

Views: 117

Answers (1)

Garrison Neely
Garrison Neely

Reputation: 3289

You'd use OnClientItemSelected to call a JavaScript function that could read the extended TextBox's value, then does something with that value (like write it to another input as you suggest). That would be 2.

As for 1, there are a few options:

  • Handle OnClientPopulated, and see if you can get a list of the items returned, if one, default the extended textbox.
  • If that doesn't work, you could always call the web method yourself in jQuery and see if only one result is returned.

Upvotes: 1

Related Questions