Click here to Skip to main content
15,896,379 members
Please Sign up or sign in to vote.
1.57/5 (3 votes)
See more:
I want to use jquery autocomplte for multiple textboxs for calling one webmethod in asp.net
Posted
Updated 24-Feb-16 21:28pm

Quote:
I want to use jquery autocomplte for multiple textboxs for calling one webmethod in asp.net
What's the problem? Call the same autocomplete on other textbox too(Use ID property with function like below). It's sample format, you need to customize the script based on your need.
JavaScript
$("[id$='TextBox1']").autocomplete({
                source: datafromServer
            });

JavaScript
$("[id$='TextBox2']").autocomplete({
                source: datafromServer
            });

3 Different Approaches for Implementing the JQuery Autocomplete with ASP.NET[^]
 
Share this answer
 
Comments
Member 8547973 2-Jan-14 5:33am    
Thank you sir for answer. but problem is, first function call and second function not call in sequence.
thatraja 2-Jan-14 5:35am    
You didn't share much details in your question. Share the code in your question
Member 8547973 2-Jan-14 5:44am    
$(document).ready(function () {
$("#ContentPlaceHolder1_txtPreCity").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "member-registration.aspx/GetCity",
data: "{'_countriesId':'" + document.getElementById("#ContentPlaceHolder1_txtPreCity").value + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert("Error");
}
});
},
minLength: 1,
focus: function (event, ui) {
$("#ContentPlaceHolder1_txtPreCity").val(ui.item.Name);
return false;
},
select: function (event, ui) {
$("#ContentPlaceHolder1_txtPreCity").val(ui.item.Name);
$("#ContentPlaceHolder1_txtPreCity").val(ui.item.value);
return false;
}
}).data('autocomplete')._renderItem = function (ul, item) {
return $('<li>').data('item.autocomplete', item).append('' + item.Name + '').appendTo(ul);
};
$("#ContentPlaceHolder1_txtCity").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "listofoba.aspx/GetCity",
data: "{'_countriesId':'" + document.getElementById("#ContentPlaceHolder1_txtCity").value + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert("Error");
}
});
},
minLength: 1,
focus: function (event, ui) {
$("#ContentPlaceHolder1_txtCity").val(ui.item.Name);
return false;
},
select: function (event, ui) {
$("#ContentPlaceHolder1_txtCity").val(ui.item.Name);
$(".ContentPlaceHolder1_txtCity").val(ui.item.value);
return false;
}
}).data('autocomplete')._renderItem = function (ul, item) {
return $('<li>').data('item.autocomplete', item).append('' + item.Name + '').appendTo(ul);
};
});
thatraja 2-Jan-14 5:47am    
Include that in your question
Member 8547973 2-Jan-14 5:52am    
1. $("#ContentPlaceHolder1_txtPreCity").autocomplete() /* This is work* /
2. $("#ContentPlaceHolder1_txtCity").autocomplete() /* This is not work* /

if change the 1 function replace by 2 and 2 replace by 1 then 2 worked but 1 not worked
See:- http://jqueryui.com/autocomplete/[^]

This will gives you the idea.......
 
Share this answer
 

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