Search code examples
c#asp.netentity-frameworkautocompleteajaxcontroltoolkit

Textbox with autocomplete


I am programming with Visual Studio 2008 and making a web application using .NET Framework 3.5 with C#. All DAL linked with an powerfull entity framework wrapper (similar to the one that VS.net 2010 would use.) I'm having a textbox used for a search on first and lastname. The problem i'm having is that i'm using AJAX Control Toolkit 2.0 which provides an Auto complete extender but, by using a WebServices (asmx). Is there any other way to use the auto complete without using a webservice?

Regards,

Simon

P.s.: Sorry for my english, i do my best :)!


Solution

  • Yes, you can mark a method in a codebehind file as a webmethod:

       public partial class Products : System.Web.UI.Page 
       { 
         [System.Web.Services.WebMethod()] 
          [System.Web.Script.Services.ScriptMethod()] 
          public static string[] GetTerms(string prefix) 
          {
            // Put your logic here
          }
       }
    

    See ASP.NET AJAX callbacks to Web Methods in ASPX pages.

    Also, if you use NET 3.5 you can use the later Toolkit which incorporates the ComboBox, which is essentially a databound auto-complete control.