aspxtextbox中的多个自动完成 [英] multiple autocomplete in aspxtextbox

查看:93
本文介绍了aspxtextbox中的多个自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在aspxtextbox中实现autoComplete,如下所示:



//脚本

i implement autoComplete in aspxtextbox like this :

//Script

function OnUserChange(s, e) {
            $(s.GetInputElement()).autocomplete({
                source: function (request, response) {
                    $.ajax({
                        type: 'POST',
                        contentType: "application/json; charset=utf-8",
                        url: global.path + '/Mail/NewMail.aspx/GetUsers',
                        data: "{'keyword':'" + request.term + "'}",
                        dataType: "json",
                        async: false,
                        success: function (data) {
                            data = jQuery.parseJSON(data.d);
                            response($.map(data, function (item) {
                                return {
                                    label: item.FullName,
                                    value: item.FullName,
                                    id: item.UserID
                                }
                            }))
                        }
                    });
                }
            });
        }





// html



//html

<dx:ASPxTextBox ID="txtTo"  runat="server" Width="500px">
       <ClientSideEvents Init="function(s, e) {
        OnUserChange(s, e); 
          }" />
</dx:ASPxTextBox>







//让用户在auotocomplete文本框中使用它

//背后的代码




//get user to use it in auotocomplete textbox
//code behind

[WebMethod]
       public static string GetUsers(string keyword)
       {
           User user = new User();
           string jsonData = JsonConvert.SerializeObject(user.GetAllUsers(keyword));


           return jsonData;


       }







thi s代码给我单值,它工作正常

我怎么能得到多个值自动完成像Facebook

请帮助我




this code give me single value and it work ok
how can i get multiple values autocomplete like facebook
please help me

推荐答案

(s.GetInputElement())。autocomplete({
source: function (request,response){
(s.GetInputElement()).autocomplete({ source: function (request, response) {


.ajax({
type:' POST'
contentType: application / json; charset = utf-8
url:global.path + ' / Mail / NewMail .aspx / GetUsers'
数据: {'keyword':' + request.term + '}
dataType: json
async: false
成功: function (data){
data = jQuery.parseJSON(data.d);
response(
.ajax({ type: 'POST', contentType: "application/json; charset=utf-8", url: global.path + '/Mail/NewMail.aspx/GetUsers', data: "{'keyword':'" + request.term + "'}", dataType: "json", async: false, success: function (data) { data = jQuery.parseJSON(data.d); response(


.map(data, function (item){
return {
label:item.FullName,
值:item.FullName,
id:item.UserID
}
}))
}
});
}
});
}
.map(data, function (item) { return { label: item.FullName, value: item.FullName, id: item.UserID } })) } }); } }); }





// html



//html

<dx:ASPxTextBox ID="txtTo"  runat="server" Width="500px">
       <ClientSideEvents Init="function(s, e) {
        OnUserChange(s, e); 
          }" />
</dx:ASPxTextBox>







//让用户在auotocomplete文本框中使用它

//背后的代码




//get user to use it in auotocomplete textbox
//code behind

[WebMethod]
       public static string GetUsers(string keyword)
       {
           User user = new User();
           string jsonData = JsonConvert.SerializeObject(user.GetAllUsers(keyword));


           return jsonData;


       }







thi s代码给我单值,它工作正常

我怎样才能获得多个值自动完成像facebook

请帮帮我




this code give me single value and it work ok
how can i get multiple values autocomplete like facebook
please help me


这篇关于aspxtextbox中的多个自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆