AutoCompleteExtender在VS2010中调试时能够从数据库中查询相关的结果,实现自动提示功能,但是当我把这个网站发布后,在iis中配置这个生成的网站,然后在IE地址栏中输入刚才配置好的地址,就不能实现这个功能,没有显示任何数据
   弄了挺久的 还是不知道怎么回事

解决方案 »

  1.   

    你看看是不是其他的浏览器设置问题 看看有么有禁用autocomplete
      

  2.   

    看一下那个dll是否存在,或者是网站上是否有下拉项存在。
      

  3.   


    在设计页面AutoCompleteExtender这个控件不显示
    在HTML中式这样写的:
     <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>         
        <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" 
                        TargetControlID="txtKeyword" Enabled="True" ServicePath="~/Landing/GetKeywords.asmx" 
                        ServiceMethod="GetKeyword" CompletionSetCount="7" MinimumPrefixLength="1">
                    </cc1:AutoCompleteExtender> 
      

  4.   

     public string[] GetKeyword(string prefixText, int count)
        {
            SqlConnection conn = new SqlConnection("Data Source=192.168.1.112;Initial Catalog=SA;Integrated Security=True");
            string sql = "SELECT TOP " + count + " * FROM 表 WHERE name LIKE '%" + prefixText + "%' ";
                    SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
          adapter.Fill(ds);
            List<string> list = new List<string>();        foreach (DataRow row in ds.Tables[0].Rows)
            {
              string keyword = Convert.ToString(row["name"]);
                list.Add(keyword);
              
            }        conn.Dispose();
            conn.Close();
            return list.ToArray();
        
             
        }
    主要是从这个页面读取的数据,然后填充到数组,是不是这里面写的不对呢?
      

  5.   

    AjaxControlToolkit.dll这个玩意在发布的程序中存在吗?
      

  6.   

     存在的,在bin文件夹里面  还有很多的pdb文件
     用的是4.1版本的     
      

  7.   

    类中这个:[System.Web.Script.Services.ScriptService]特性没有注释掉吧
      

  8.   

    整体代码:
    public class GetKeywords : System.Web.Services.WebService
    {    public GetKeywords()
        {         
        }    [WebMethod]
        public string[] GetKeyword(string prefixText, int count)
        {
            SqlConnection conn = new SqlConnection("Data Source=192.168.1.112;Initial Catalog=SA;Integrated Security=True");
            string sql = "SELECT TOP " + count + " * FROM 表 WHERE name LIKE '%" + prefixText + "%' ";
             SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
          adapter.Fill(ds);
            List<string> list = new List<string>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
              string keyword = Convert.ToString(row["name"]);
                list.Add(keyword);
              
            }        conn.Dispose();
            conn.Close();
            return list.ToArray();
        
             
        }}
    感觉没有错啊  帮忙看看 谢谢
      

  9.   

    看一下类前面有没有下面的代码:
    /// <summary>
    /// Summary description for Role
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // 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 GetKeywords : System.Web.Services.WebService
    {
    ....
    }
      

  10.   

    [System.Web.Script.Services.ScriptService]
    这玩意要加上滴
      

  11.   

    有人说是要在项目引用里,选中System.Web.Extension   和 System.Web.Extension.Design
    这两个也是在哪里呢?
      

  12.   

    直接在IIS中的虚拟目录定位到你的源代码,那样在浏览器中能实现下拉吗?
      

  13.   

    跟上面的无关。要不你写个Hello World!的程序发布测试一下。
      

  14.   

    还是不行 不能实现下拉  没有显示 
    是不是加的AJAX控件的问题呢?
      

  15.   

    那个控件是没问题的,我用的也是4.1的,要不你在里面添加一个测试的.ASMX文件,里面有一个Hello Wrold的测试程序,看那个是否正常。
      

  16.   

    重新加了个.asmx文件,把刚才的覆盖了,运行时好像什么都没有[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    //若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 
    // [System.Web.Script.Services.ScriptService]
    public class GetKeywords : System.Web.Services.WebService {    public GetKeywords () {        //如果使用设计的组件,请取消注释以下行 
            //InitializeComponent(); 
        }    [WebMethod]
        public string HelloWorld() {
            return "Hello World";
        }
        
    }
      

  17.   

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    //若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。  
    [System.Web.Script.Services.ScriptService]
    public class GetKeywords : System.Web.Services.WebService {  public GetKeywords () {  //如果使用设计的组件,请取消注释以下行  
      //InitializeComponent();  
      } [WebMethod]
        public string[] HelloWorld()
        {
            return new string[1] { "Hello World" };
        }    
    }引用中改一下:
     <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"  
      TargetControlID="txtKeyword" Enabled="True" ServicePath="~/Landing/GetKeywords.asmx"  
      ServiceMethod="HelloWorld" CompletionSetCount="7" MinimumPrefixLength="0">
      </cc1:AutoCompleteExtender> 
    试试看
      

  18.   

    恩 你的是对的  这样做后 能显示hello word
    并且发布后也行  我的那个怎么就不行
      

  19.   

     是不是数据库连接字符串有问题了。你在里面加上异常处理看看。try
    {
     SqlConnection conn = new SqlConnection("Data Source=192.168.1.112;Initial Catalog=SA;Integrated Security=True");
      string sql = "SELECT TOP " + count + " * FROM 表 WHERE name LIKE '%" + prefixText + "%' ";
      SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
      DataSet ds = new DataSet();
      adapter.Fill(ds);
      List<string> list = new List<string>();
      foreach (DataRow row in ds.Tables[0].Rows)
      {
      string keyword = Convert.ToString(row["name"]);
      list.Add(keyword);
        
      }  conn.Dispose();
      conn.Close();
      return list.ToArray();
    }
    catch(Exception ex)
    {
       return new string[1] { ex.ToString() };
    }
      

  20.   

    很感谢PitTroll  改好了 
      

  21.   

    关于楼主说的这个问题,我研究了一个星期,使用AJAX下的AUTOCOMPLETEEXTEND控件完美实现了GOOGLE式的智能提示。为此了写了一个详细的文档,一步一步详细说明实现此功能的步骤,还有一个源代码实例,还有AJAX包,一定能够帮助你实现这个功能,在这下载:http://download.csdn.net/source/3462200
    如果运行过程中还遇到什么问题,可以联系我QQ:120283955