Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone ,

how to do the auto complete text box like google search... will you please anyone help me to solve this

thanks in advance

Velsamy A
Posted
Comments
DamithSL 3-Nov-14 9:31am    
please read the Code Project Quick Answers FAQ[^]
Have you searched or Googled for a solution?

A simple Google search query would have returned the answer, which would be that "you can use jQuery UI for this". jQuery UI has a set of functions that are used for creating dynamic web pages. Autocomplete is a feature where you provide the user with a set of possible results depending on his current input value.

Go to this[^] page and test the code from the jQuery UI. You will be able to view the source code of the sample too.
 
Share this answer
 
Comments
avelsamy 4-Nov-14 0:17am    
already i have used this code , but instead of hard coded , i need to get the string values from database.(value field and text field)
Afzaal Ahmad Zeeshan 4-Nov-14 0:53am    
You can for that get the hardcoded string from a variable that takes the values from database. Simple!
avelsamy 4-Nov-14 1:47am    
the problem is here i m using ajax post web method to call the webuser control's web method but its not firing ... i ll share the code here...


$(function () {
var availableTags = getbroker()
$("#txt_broker").autocomplete({
source: availableTags
});
});





function getbroker() {
$.ajax({
type: "POST",
url: "swith.aspx/get_broker",
data: '{}',
contentType: "application/json",
dataType: "json",
success: function (msg) {
alert('workingajax');
},
error: function () {
alert('error');
}
});
}

server side
------------
<webmethod()>
Public Shared Function get_broker() As Integer
return some value
end function
here i have put breakpoint its not firing.... but i have used the same code in my another aspx page its working fine. here i m using ascx page ... is there any problem on that

here error alert is executing
Afzaal Ahmad Zeeshan 4-Nov-14 2:11am    
That is because you're not passing the values in the JavaScript, you need to be using an assignment operator to transfer the data returned by the ASP.NET code to the JS code.

For example,

success: function (data) {
// assign it to the variable which would contain
// the list for the AutoComplete list.
autoCompleteList = data;
}

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