我正在尝试在文本框上设置自动填充功能。我用过这个例子: http://sapnashukla.blogspot.com/2014/05/to-create-autocomplete-textbox-without.html
我无法得到结果。当我尝试输入文本时,我在TextBox之后得到了这个结果:
Type test
<
!
D
O
C
T
Y
P
E
h
t
m
l
<
>
and etc..
我应该为此做些什么?
有人可以解释并帮助我吗?
我也试过这个: aspx.cs
public partial class manage:System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e)
{
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetCompletionList(string prefixText, int count)
{
return AutoFillProducts(prefixText);
}
private static List<string> AutoFillProducts(string prefixText)
{
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["BNConnectionString"].ConnectionString;
using (SqlCommand com = new SqlCommand())
{
com.CommandText = "select person from table where " + "person like @Search + '%'";
com.Parameters.AddWithValue("@Search", prefixText);
com.Connection = con;
con.Open();
List<string> countryNames = new List<string>();
using (SqlDataReader sdr = com.ExecuteReader())
{
while (sdr.Read())
{
countryNames.Add(sdr["person"].ToString());
}
}
con.Close();
return countryNames;
}
}
}
}
ASPX:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="manage.aspx.cs" Inherits="XX.Mobilus.manage" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server" MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1"
CompletionInterval="1" ServiceMethod="GetCompletionList" UseContextKey="True" TargetControlID="TextBox1">
</ajaxToolkit:AutoCompleteExtender>
</asp:Content>
答案 0 :(得分:0)
博客只有一个(1)参数来自其函数
,您是否尝试删除“,int count”?