I have a texbox inside a templatefield in a gridview. For this textbox I have defined an autocompleteextender with its TargetControlID set to "myTextbox" which is working just fine. At the same time, for the OnClientItemSelected property I have defined a javascript function which should set the value of my textbox, but my question is how can I get the the name of this textbox using javascript?

My control snippet like this:

ajaxToolkit:AutoCompleteExtender TargetControlID="txtValue" onClientItemSelected="SetValue"

And my code looks like this:

function SetValue(sender, eventArgs){
  var TitleValue = eventArgs.get_value(); 
  /* do smth with this value */
  /* set the new value to my textbox ? */
}

Your suggestions and ideas are very much appreciated. Thank you a lot!

有帮助吗?

解决方案

You should be able to get the textbox control using:

sender.get_element()

For extenders, get_element() returns the targeted control, for script controls, it's the element that represents that control.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top