问题描述
我在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
推荐答案
// 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中的多个自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!