admin管理员组文章数量:1022560
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 badges2 Answers
Reset to default 1function 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"
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 badges2 Answers
Reset to default 1function 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"
本文标签: javascriptajaxToolKit autoCompleteExtender OnClientItemSelectedStack Overflow
版权声明:本文标题:javascript - ajaxToolKit autoCompleteExtender OnClientItemSelected - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745564806a2156383.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论