Translate

> > ASP.NET Jquery Auto complete with selected value

ASP.NET Jquery Auto complete with selected value

Posted on Friday, March 25, 2016 | No Comments


 function InitAutoCompl3() {

                                         
                                             $("#<%=txtAccountName.ClientID %>").autocomplete({
                                                 source: function (request, response) {
                                                     $.ajax({
                                                         url: '<%=ResolveUrl("~/DataWebService.asmx/GetAccounts2") %>',
                                                         data: "{ 'prefixText': '" + request.term + "'}",
                                                         dataType: "json",
                                                         type: "POST",
                                                         contentType: "application/json; charset=utf-8",
                                                         success: function (data) {

                                                             response($.map(data.d, function (item) {
                                                                 return {
                                                                     label: item.split('~')[1],
                                                                     val: item.split('~')[0]
                                                                 }
                                                             }))
                                                         },
                                                         error: function (response) {
                                                             alert(response.responseText);
                                                         },
                                                         failure: function (response) {
                                                             alert(response.responseText);
                                                         }
                                                     });
                                                 },
                                                 select: function (e, i) {
                                                     $("#<%=HFAcId2.ClientID %>").val(i.item.val);
                                                 },
                                                 minLength: 1
                                             });
                                     };


Leave a Reply

Powered by Blogger.