My Code Behind is :
[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod]
public string[] GetUsers(string prefixText)
{
List<string> names
= new List<string>() { "Alpha", "Beta", "Gamma", "Delta", "Omega","Ajay","Aman"};
return names.ToArray();
}
and aspx. code is
> <%@ Page Title="" Language="C#"
> MasterPageFile="~/Site.Master"
> AutoEventWireup="true"
> CodeBehind="AutoExt.aspx.cs" Inherits="WebApplication1.AutoExt" %>
>
> <%@ Register TagPrefix="AjaxToolKit"
> Assembly="AjaxControlToolkit"
> Namespace="AjaxControlToolkit" %>
> <asp:Content ID="Content1"
> ContentPlaceHolderID="HeadContent"
> runat="server"> </asp:Content>
> <asp:Content ID="Content2"
> ContentPlaceHolderID="MainContent"
> runat="server">
> +
> <asp:ScriptManager EnablePartialRendering="true"
> ID="ScriptManager1" runa开发者_运维技巧t="server">
> </asp:ScriptManager>
> <asp:UpdatePanel ID="upd" runat="server">
> <ContentTemplate>
> <table>
> <tr>
> <td>
> User:
> </td>
> <td>
> <asp:TextBox ID="tbUser"
> runat="server"></asp:TextBox>
> </td>
> <td>
>
> </td>
> <td>
> <img id="processing" style="visibility:
> hidden" src="Images/ajax-loading.gif"
> />
> </td>
> <td>
>
> </td>
> <td>
> <AjaxToolKit:AutoCompleteExtender
> ID="AutoCompleteExtender1"
> runat="server"
> CompletionInterval="100"
> CompletionSetCount="12"
> EnableCaching="false"
> MinimumPrefixLength="1"
> ServiceMethod="GetUsers"
> TargetControlID="tbUser">
> </AjaxToolKit:AutoCompleteExtender>
> </td>
> </tr>
> </table>
> </ContentTemplate>
> </asp:UpdatePanel> </asp:Content>
But AutoCompleteExtender not Working
Can you check with attribute in web service [System.Web.Script.Services.ScriptService] This attribute will the Web Service to be called from script, using ASP.NET AJAX
精彩评论