File: FileService.asmx
<%@ WebService Language="C#" Class="FileService" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.IO;
using System.Linq;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class FileService : System.Web.Services.WebService {
[WebMethod]
public string[] GetSuggestions(string prefixText, int count)
{
DirectoryInfo dir = new DirectoryInfo("c:\\windows");
return dir
.GetFiles()
.Where( f => f.Name.StartsWith(prefixText) )
.Select( f => f.Name )
.ToArray();
}
}
File: AutoCompleteWebService.aspx
<%@ Page Language="C#" %>
<%@ Register TagPrefix="ajax" Namespace="AjaxControlToolkit"
Assembly="AjaxControlToolkit" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Show AutoComplete Web Service