AutoComplete AJAX Control with Ajax.NET Professional

Michael Schwarz on Friday, November 11, 2005

I have finished a more complex auto complete textbox you can use in you Ajax.NET Professional [1] web application. The control can be added on the server like other HtmlControls:

AjaxAutoComplete textBox1 = new AjaxAutoComplete(); textBox1.ID = "hans1"; placeHolder1.Controls.Add(textBox1);

You have to specify where you want to get the data back. There is a delegate that must point to a public Ajax.NET method, i.e. like this:

textBox1.OnAutoComplete = new AjaxAutoComplete.AutoCompleteHandler(this.OnAutoComplete);

The this.OnAutoComplete method looks like this:

[AjaxPro.AjaxMethod] public object[] OnAutoComplete(string value, int count) { string[] s = new string[(value.Length < count ? value.Length : count)];  for(int i=0; i<s.Length; i++) { s[i] = value.Substring(0, i+1); } return s; }

In a later version I will add the feature to override the render method to include more colums. The auto complete control is working with Internet Explorer and Firefox, other browsers have to be tested. You can download the source code [2] at the Google group [3].