[英]AutoComplete TextBox without Webservices in ASP.NET
我正在嘗試在文本框中設置自動完成功能。 我使用了以下示例: 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
公共局部類管理: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>
該博客的功能只有一個(1)參數
,您是否嘗試過刪除“,int count”?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.