自动完成扩展不能调用Web服务方法 [英] Auto complete Extender not invoking the Web service method

查看:91
本文介绍了自动完成扩展不能调用Web服务方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是AJAX自动完成扩展控制在我的ASP.net页的文本框:

I am using an ajax auto complete extender control in my ASP.net page for a text box :

<td align="left>
  <asp:TextBox ID="txtAutoComplete" runat="server" MaxLength="200" Width="50%">         </asp:TextBox>

 <asp:AutoCompleteExtender ID="txtAutoComplete_AutocompleteExtender" runat="server"
                        Enabled="true" TargetControlID="txtAutoComplete" UseContextKey="true" ServiceMethod="GetItemsList" ServicePath="~/AutoCompleteWebService.asmx"
                      MinimumPrefixLength="3" CompletionSetCount="12" DelimiterCharacters=";" OnClientPopulating="ShowProcessImage" OnClientPopulated="HideProcessImage">
                    </asp:AutoCompleteExtender>
</td>

我创建了一个Web服务,并从自动控制扩展调用此方法:

I created a webservice and invoked this method from the auto control extender :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace TestChart
{
    /// <summary>
    /// Summary description for AutoCompleteWebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 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 AutoCompleteWebService : System.Web.Services.WebService
    {
        public AutoCompleteWebService(){
        }
        [WebMethod]
        public  string[] GetItemsList(string Prefix,int count)
        {
            char c1;
            char c2;
            char c3;`enter code here`

            if (count == 0)
            {
                count = 10;
            }
             Random rnd =new Random();
             List<string> items = new List<string>();
             for (int i = 0; i < count; i++)
             {
                 c1 = Convert.ToChar(rnd.Next(65, 90));
                 c2 = Convert.ToChar(rnd.Next(97, 122));
                 c3 = Convert.ToChar(rnd.Next(97, 122));
                 items.Add(Prefix + c1 + c2 + c3);
             }
                 return items.ToArray();
        }
    }
}

如果我单独运行此WebService它的正常工作,但是当我运行该项目的文本框中没有显示自动完成选项。

If i individually run this webservice it's working fine but when I the run the project the text box is not showing autocomplete options.

任何人都可以请帮我在分析错误。

Can anyone please help me in analyzing the mistake.

在此先感谢

推荐答案

使用

[WebMethod]
        public  string[] GetItemsList(string PrefixText,int count)
        {
            char c1;
            char c2;
            char c3;`enter code here`

            if (count == 0)
            {
                count = 10;
            }
             Random rnd =new Random();
             List<string> items = new List<string>();
             for (int i = 0; i < count; i++)
             {
                 c1 = Convert.ToChar(rnd.Next(65, 90));
                 c2 = Convert.ToChar(rnd.Next(97, 122));
                 c3 = Convert.ToChar(rnd.Next(97, 122));
                 items.Add(PrefixText + c1 + c2 + c3);
             }
                 return items.ToArray();
        }

这篇关于自动完成扩展不能调用Web服务方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆