Возможно ли иметь 2 или более текстовых полей AutoCompleteExtender
на странице 1 asp? У меня 1 работает, но когда я добавил еще одно текстовое поле с автозаполнением, оно недавно добавило текстовое поле AutoCompleteExtender не запускается.
Это мой код Textbox3
<asp:TextBox ID="TextBox3" CssClass="rcorner" placeholder="Tell us about you DREAM HOUSE" runat="server" AutoPostBack="True"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="SearchCustomers"
MinimumPrefixLength="1"
CompletionInterval="1" EnableCaching="false" CompletionSetCount="10"
TargetControlID="TextBox3"
BehaviorID="AutoCompleteEx2"
ID="AutoCompleteExtender1" runat="server">
</cc1:AutoCompleteExtender>
Веб-метод Textbox3
<System.Web.Script.Services.ScriptMethod(),
System.Web.Services.WebMethod()>
Public Shared Function SearchCustomers(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim conn As New SqlConnection With {.ConnectionString = "Server=southlink-dev.database.windows.net;Database=SaricasaDBO;User=SL-dev-user765;Pwd=Cr33dMa666;"}
Dim strsql As String = "select subcat from subcategory where subcat like '%" & prefixText & "%'"
Dim cmd As SqlCommand = New SqlCommand(strsql, conn)
conn.Open()
'cmd.Parameters.AddWithValue("@SearchText", prefixText)
Dim customers As List(Of String) = New List(Of String)
Dim sdr As SqlDataReader = cmd.ExecuteReader
While sdr.Read
customers.Add(sdr("subcat").ToString)
End While
conn.Close()
Return customers
End Function
Textbox1
<asp:TextBox ID="TextBox1" placeholder="Location" runat="server" AutoPostBack="True"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="SearchLocation"
MinimumPrefixLength="1"
CompletionInterval="1" EnableCaching="false" CompletionSetCount="10"
TargetControlID="TextBox1"
BehaviorID="AutoCompleteEx"
ID="AutoCompleteExtender2" runat="server">
</cc1:AutoCompleteExtender>
Веб-метод Textbox1
<System.Web.Script.Services.ScriptMethod(),
System.Web.Services.WebMethod()>
Public Shared Function SearchLocation(ByVal sql As String, ByVal count As Integer) As List(Of String)
Dim conn As New SqlConnection With {.ConnectionString = "Server=southlink-dev.database.windows.net;Database=SaricasaDBO;User=SL-dev-user765;Pwd=Cr33dMa666;"}
Dim strsql As String = "select subcat from subcategory inner join dbo.category on subcategory.cat_id= category.cat_id where subcat like '%" & sql & "%' AND category.description='Location' "
Dim cmd As SqlCommand = New SqlCommand(strsql, conn)
conn.Open()
'cmd.Parameters.AddWithValue("@SearchText", prefixText)
Dim loc As List(Of String) = New List(Of String)
Dim sdr As SqlDataReader = cmd.ExecuteReader
While sdr.Read
loc.Add(sdr("subcat").ToString)
End While
conn.Close()
Return loc
End Function
И Textbox1, и Textbox3 находятся на одной странице