ASP.NET - autocomplete textbox in asp.net with database using XMLHttpRequest

Asked By gowri shankar on 24-Feb-12 05:23 AM
Hi,
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 - http://mvark.blogspot.com/2009/02/ajax-frameworks-for-aspnet.html

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 -
http://blogs.msdn.com/delay/archive/2007/03/30/autocomplete-how-to-create-a-multi-word-auto-complete-text-box.aspx
http://mvark.blogspot.com/2007/07/my-experiments-with-aspnet-ajax.html
kalpana aparnathi replied to gowri shankar on 24-Feb-12 05:35 AM
hi,

Try below code:

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

More detail:click here

One more link:click here

Links:
http://weblogs.asp.net/rashid/archive/2008/01/14/ajaxdatacontrols-gridview-part-two.aspx

http://blog.ashmind.com/index.php/2007/06/21/client-side-databinding-with-aspnet-ajax-futures/

http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

Regards,

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
regards
D