你一定错过了jQuery的自动完成选项,不正是你想要的。这将匹配马克·亚当斯,当你键入A,d等
编辑
而对于ajaxtoolkit AutoCompleteExtender,我怕你没有得到任何选项等同于jQuery的matchContains的。但你可以用服务方法轻松完成。其设置为...
ServiceMethod="GetNameList"
其中GetNameList包含如何匹配数据的整个逻辑。例如。
public partial class _Default : System.Web.UI.Page {
[WebMethod]
public static string[] GetNameList(string prefixText, int count) {
string sql = String.Format("select name from customers where name like @given_name");
List<string> nameList = new List<string>();
using (SqlConnection connection = new SqlConnection("Integrated Security=SSPI;Initial Catalog=Northwind;Data Source=."))
using (SqlCommand command = new SqlCommand(sql, connection)) {
connection.Open();
command.Parameters.AddWithValue("@given_name", "%"+prefixText"%");
using (SqlDataReader reader = command.ExecuteReader()) {
while (reader.Read()) {
nameList.Add(reader.GetString(0));
}
}
}
return nameList.ToArray();
}
}
下面是代码行,它进行匹配。
command.Parameters.AddWithValue("@given_name", "%"+prefixText"%");
检查Ajax ToolKit的编辑。 – simplyharsh 2009-07-17 06:50:42