我在文本框上有一个自动填充扩展器,它将记录显示为数据库中的列表,但是我点击了texbox并开始输入任何内容.我的HTML代码是
Enabled="True" TargetControlID="TextBox1" ServicePath="~/WebService.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="2"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="20"
DelimiterCharacters=";, :"
ShowOnlyCurrentWordInCompletionListItem="true" >
我的网络服务是
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using MySql.Data.MySqlClient;
using System.Configuration;
///
/// Summary description for WebService
///
[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 WebService : System.Web.Services.WebService {
public WebService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public static List GetCompletionList(string prefixText, int count)
{
MySqlConnection con = new MySqlConnection(ConfigurationManager.AppSettings["cn"]);
if (con.State == ConnectionState.Closed)
con.Open();
MySqlCommand cmd = new MySqlCommand("SELECT gotra FROM tbgotra WHERE gotra LIKE '%" + prefixText + "%'",con);
List k = new List();
using (MySqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
k.Add(sdr["gotra"].ToString());
}
}
con.Close();
return k;
}
}