Ajax ASP.Net Tutorial

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">

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        lblSelectedFileName.Text = txtFileName.Text;
    }



    Show AutoComplete Web Service


    
    

    
            id="lblFileName"
        Text="File Name:"
        AssociatedControlID="txtFileName"
        Runat="server" />
            id="txtFileName"
        AutoComplete="off"
        Runat="server" />
            id="ace1"
        TargetControlID="txtFileName"
        ServiceMethod="GetSuggestions"
        ServicePath="~/FileService.asmx"
        MinimumPrefixLength="1"
        runat="server" />
            id="btnSubmit"
        Text="Submit"
        OnClick="btnSubmit_Click"
        Runat="server"/>
    
            id="lblSelectedFileName"
        runat="server" />