javascript - ajaxToolKit autoCompleteExtender OnClientItemSelected - Stack Overflow

I am trying to implement an autoCompleteExtender into my project. Currently I am using the OnClientItem

I am trying to implement an autoCompleteExtender into my project. Currently I am using the OnClientItemSelected property to call a javascript on the client side. Is there a way (using another property or some other code) that will let me call a method in the code behind when the user selects an option?

I am trying to implement an autoCompleteExtender into my project. Currently I am using the OnClientItemSelected property to call a javascript on the client side. Is there a way (using another property or some other code) that will let me call a method in the code behind when the user selects an option?

Share Improve this question asked Aug 7, 2012 at 14:22 theNoobProgrammertheNoobProgrammer 9323 gold badges15 silver badges34 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 1
function AutoCompleteEx_OnClientItemSelected(sender, args) {
     __doPostBack(sender.get_element().name, '');
}

On server side handle TextChanged event of extended textbox.

For this you need to return the list from web service method with ID and Text

Here "lst" is the actual list with data from your data source.

List<string> items = new List<string>(count);
        for (int i = 0; i < lst.Count; i++)
        {
            string str =AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(lst[i].Text,Convert.ToString(lst[i].IDValue));                
            items.Add(str);

        }
        return items.ToArray();

Then simple javascript

function GetID(source, eventArgs )
    {
        var HdnKey = eventArgs.get_value();
        document.getElementById('<%=hdnID.ClientID %>').value = HdnKey;
    }

and dont forget to set the attribute in auto plete extender OnClientItemSelected="GetID"

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745564807a4633328.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信