AjaxToolKit:AutoCompleteExtender不工作

时间:2011-05-10 08:43:11

标签: asp.net-ajax

我的代码背后是:

[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();
}

和aspx。代码是

> <%@ 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" runat="server">
>     </asp:ScriptManager>
>     <asp:UpdatePanel ID="upd" runat="server">
>         <ContentTemplate>
>             <table>
>                 <tr>
>                     <td>
>                         User:&nbsp;&nbsp;
>                     </td>
>                     <td>
>                         <asp:TextBox ID="tbUser"
> runat="server"></asp:TextBox>
>                     </td>
>                     <td>
>                         &nbsp;
>                     </td>
>                     <td>
>                         <img id="processing" style="visibility:
> hidden" src="Images/ajax-loading.gif"
> />
>                     </td>
>                     <td>
>                         &nbsp;
>                     </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>

但AutoCompleteExtender无法正常工作

1 个答案:

答案 0 :(得分:1)

您可以在网络服务中查看属性吗? [System.Web.Script.Services.ScriptService] 此属性将使用ASP.NET AJAX从脚本调用Web Service