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

问题描述

你好,

请帮助,我在我的项目中使用了ajax自动完成扩展器.
我已经在我的aspx代码中编写了一个方法,但是该方法没有被调用.请帮忙!!!

谢谢.

Hello,

Please help, i have taken ajax autocomplete extender in my project.
I have written a method in my aspx code behind but that method is not getting called. Please help!!!

Thankyou.

推荐答案

ServicePath="AutoComplete.asmx"


从您的代码中

在CS页面上

[System.web.Webservices.WebMethod]


From your code

at CS page

[System.web.Webservices.WebMethod]

public string[] GetCountriesList(string prefixText)

   {

       DataSet dtst = new DataSet();

       SqlConnection sqlCon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);

       string strSql = "SELECT CountryName FROM Tbl_Countries WHERE CountryName LIKE '" + prefixText + "%' ";

       SqlCommand sqlComd = new SqlCommand(strSql, sqlCon);

       sqlCon.Open();

       SqlDataAdapter sqlAdpt = new SqlDataAdapter();

       sqlAdpt.SelectCommand = sqlComd;

       sqlAdpt.Fill(dtst);

       string[] cntName = new string[dtst.Tables[0].Rows.Count];

       int i = 0;

       try

       {

           foreach (DataRow rdr in dtst.Tables[0].Rows)

           {

               cntName.SetValue(rdr["CountryName"].ToString(), i);

               i++;

           }

       }

       catch { }

       finally

       {

           sqlCon.Close();

       }

       return cntName;

   }



我希望它会起作用



I Hope It will work


I would start from creating similar example as given here:
<a href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/">http://www.asp.net/ajax/ajaxcontroltoolkit/samples/</a>



这篇关于自动完成扩展器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-31 08:31