There are migration guides on the ASP.NET AJAX homepage detailing how to convert Web Sites originally coded against the Atlas CTP to ASP.NET AJAX 1.0 Beta2. Unfortunately at this time, the AutoCompleteExtender is only included in the ASP.NET AJAX Futures November CTP but it's relatively straightforward to add the AutoCompleteExtender to an AJAX Web Site.
1. Add a reference to the Microsoft.Extensions.Preview assembly, usually located in C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025.
2. Add the elements below to the configuration\system.web\pages\controls element of the web.config file.
<addtagPrefix="asp"namespace="Microsoft.Web.Preview.UI"assembly="Microsoft.Web.Preview"/>
<addtagPrefix="asp"namespace="Microsoft.Web.Preview.UI.Controls"assembly="Microsoft.Web.Preview"/>
3. Add the ScriptManager, TextBox and AutoCompleteExtender controls to the Web Form.
<formid="form1"runat="server">
<asp:ScriptManagerID="ScriptManager1"runat="server"/>
<div>
<asp:TextBoxID="txtCity"runat="server"/>
<asp:AutoCompleteExtenderID="autoCity"runat="server"CompletionSetCount="8"TargetControlID="txtCity"MinimumPrefixLength="1"ServiceMethod="GetCities"ServicePath="AutoCompleteService.asmx"/>
</div>
</form>
4. Finally, add the Web Service that the AutoCompleteExtender will call, making sure that the Place code in seperate file checkbox is unchecked so the code is inline. The WebMethod needs to accept the prefixText and count as parameters, returning the valid list as a string array. Also note the inclusion of the Microsoft.Web.Script.Services.ScriptService attribute on the class definition.
<%@WebServiceLanguage="C#"Class="AutoCompleteService"%>
using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[Microsoft.Web.Script.Services.ScriptService]
publicclassAutoCompleteService : System.Web.Services.WebService {
[WebMethod]
publicstring[] GetCities(string prefixText, int count)
{
string[] autoCompleteWordList = { "Canberra", "Sydney", "Darwin", "Brisbane", "Adelaide", "Hobart", "Melbourne", "Perth" };
Array.Sort(autoCompleteWordList, newCaseInsensitiveComparer());
int index = Array.BinarySearch(autoCompleteWordList, prefixText, newCaseInsensitiveComparer());
if (index < 0)
{
index = ~index;
}
int matchingCount;
for (matchingCount = 0; matchingCount < count && index + matchingCount < autoCompleteWordList.Length; matchingCount++)
{
if (!autoCompleteWordList[index + matchingCount].StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase))
{
break;
}
}
String[] returnCities = newstring[matchingCount];
if (matchingCount > 0)
{
Array.Copy(autoCompleteWordList, index, returnCities, 0, matchingCount);
}
return returnCities;
}
}