ASP.NET - autocomplete textbox in with database using XMLHttpRequest

Asked By gowri shankar on 24-Feb-12 05:23 AM
Anybody help me to find solution for this question

When ever type a sentence or a single word in the text box, it will automatically display in the grid view.use ajax XMLHttpRequest object (to exchange data asynchronously with a server)
Somesh Yadav replied to gowri shankar on 24-Feb-12 05:32 AM
Depending on which ASP.NET version you are using, install the appropriate version of ASP.NET AJAX Extensions & ASP.NET AJAX ControlToolkit within which you have the AutoCompleteExtender

For more info on that, check this link -

You hook up an AutoCompleteExtender to the TextBox by specifying the ID of the TextBox through the TargetControlID property of AutoCompleteExtender -

<asp:TextBox ID="TextBox1" runat="server" Width="300" />
      <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
        TargetControlID="TextBox1" ServiceMethod="GetCompletionList"
        MinimumPrefixLength="0" />

The AutoComplete Extender expects its "auto suggest" list through a web service. It has over 10 properties including client side caching & a CompletionSetCount property that decides the number of suggestions to be retrieved from the web service.

For complete code samples, check these links -
kalpana aparnathi replied to gowri shankar on 24-Feb-12 05:35 AM

Try below code:

function GetResponse(url, Response)
  if(navigator.appName == "Microsoft Internet Explorer")
    var xhttp = new ActiveXObject("Msxml2.XMLHTTP");
    var xhttp = new XMLHttpRequest();
  }"GET", url, true);
  xhttp.onreadystatechange =
    if (xhttp.readyState == 4 && xhttp.responseText)

More detail:click here

One more link:click here



D Company replied to gowri shankar on 24-Feb-12 05:36 AM
To do this first u have to create the object of XML HTTP Request object
and than check the value and assign it to grid , something like below code snippet.

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
// instance of the XML HTTP Request object
var objXMLHTTP = new ActiveXObject( "Microsoft.XMLHTTP" );
var temp; 
//save the value of text box in temp pass it to the function
function saveingrid(temp)
 // Prepare the XMLHTTP object for a HTTP POSTtemp= temp;
//rest of the things will be like Javascript normal snippet

dont forget to put this line in for
<FORM method="POST" name="ajax" action="">   

Hope it helps