开发者

Ajax Autocompleteextender not showing the autocompletelist to choose

开发者 https://www.devze.com 2022-12-28 02:11 出处:网络
i was working ajax auto completeextender witha text box in asp.net and c#.net. i am not able to get list to choose,i have the appropriate web service method called..can anyone guide me to get theautom

i was working ajax auto completeextender witha text box in asp.net and c#.net. i am not able to get list to choose ,i have the appropriate web service method called..can anyone guide me to get the automo complete done.

<form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <div>
    <asp:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="TextBox1"
    ServiceMethod="GetCompletionList"
    ServicePath="AutoComplete.asmx"
    MinimumPrefixLength="0" 
    CompletionInterval="50"
    EnableCaching="true"
    CompletionSetCount="1"    
    DelimiterCharacters=";, :"
    ShowOnlyCurrentWordInCompletionListItem="true">        
</asp:AutoCompleteExtender>
        <asp:TextBox ID=开发者_如何学Go"TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>

and the web service method contains the following code

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class AutoComplete : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            List<string> responses = new List<string>();

            for (int i = 0; i < count; i++)

                responses.Add(prefixText + (char)(i + 65));
            return responses.ToArray();
        }
    }


Your method needs to have the following two attirubutes

[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
0

精彩评论

暂无评论...
验证码 换一张
取 消