Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i implement autoComplete in aspxtextbox like this :

//Script
JavaScript
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
ASP.NET
<dx:ASPxTextBox ID="txtTo"  runat="server" Width="500px">
       <ClientSideEvents Init="function(s, e) {
        OnUserChange(s, e); 
          }" />
</dx:ASPxTextBox>



//get user to use it in auotocomplete textbox
//code behind
C#
[WebMethod]
       public static string GetUsers(string keyword)
       {
           User user = new User();
           string jsonData = JsonConvert.SerializeObject(user.GetAllUsers(keyword));


           return jsonData;


       }



this code give me single value and it work ok
how can i get multiple values autocomplete like facebook
please help me
Posted
Comments
raju melveetilpurayil 1-Jun-15 8:51am    
autocomplete like facebook? Can you give any image to see how it works in facebook?
tranesyasd 2-Jun-15 1:23am    
like the control in this link :

http://loopj.com/jquery-tokeninput/

1 solution

The logic behind that control is
1: Styling one DIV/SPAN/UL like a TEXTBOX and insert a border less textbox in it.
2: Once the user select something from your autocomplete control it create one more div with close button or what ever and place left side of your border less textbox
3: And keep appending items in the parent DIV/SPAN/UL when user select item from auto complete control.

Happy days..

Got to the http://loopj.com/jquery-tokeninput/[^] and please use firbug to see what is happening behind the scene.

Thanks
 
Share this answer
 
Comments
tranesyasd 2-Jun-15 6:37am    
tokeninput is a plugin control i added it but how can call the function above in this control ?
raju melveetilpurayil 2-Jun-15 6:41am    
Instead of using tokeninput you can build yourown control. You already done nearly 80%, just need some css and a bit of javascript. I am not looked in to tokeninput.
tranesyasd 2-Jun-15 6:53am    
please tell me how can i do that ?
thank you
tranesyasd 3-Jun-15 1:19am    
if you have example or demo to create my own control please tell me
thank you
raju melveetilpurayil 3-Jun-15 3:28am    
I don't have any. Sorry..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900