Hi,
After almost two days of searching thru web for some simple autocompleate solution I finaly manage ti get one and make it to retreive data from my database, but not I am stuch with how to get ID of selected value (user should not see the ID only string value.
Here is my code:
aspx<%@ Page Language="VB" AutoEventWireup="false" CodeFile="VB.aspx.vb" Inherits="VB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title></head><body><form id="form1" runat="server"><div><asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods = "true"></asp:ScriptManager><asp:TextBox ID="tboxMjesto" runat="server"></asp:TextBox><cc1:AutoCompleteExtender ServiceMethod="SearchCustomers" MinimumPrefixLength="2" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10" TargetControlID="tboxMjesto" ID="AutoCompleteExtender1" runat="server" FirstRowSelected = "false" ></cc1:AutoCompleteExtender></div></form></body></html> vb Imports System.Web Imports System.Web.Configuration Imports System.Web.Services Imports System.Collections.Generic Imports System.Data.SqlClient Partial Class VB Inherits System.Web.UI.Page <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 connectionString As String = WebConfigurationManager.ConnectionStrings("xxx").ConnectionString Dim selectSQL As String = "SELECT * FROM tblMjesta Where MJESTO Like @SearchText + '%'" Dim con As New SqlConnection(connectionString) Dim cmd As New SqlCommand(selectSQL, con) cmd.Parameters.AddWithValue("@SearchText", prefixText) cmd.Connection = con con.Open() Dim customers As List(Of String) = New List(Of String) Dim a As List(Of String) = New List(Of String) Dim sdr As SqlDataReader = cmd.ExecuteReader While sdr.Read customers.Add(sdr("mjesto").ToString & " (" & sdr("SREDISTE_MJESTA").ToString & ")") a.Add(sdr("SREDISTE_MJESTA")) End While con.Close() Return customers End Function End Class webconfig <?xml version="1.0"?><configuration><appSettings/><connectionStrings><add name="xxx" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=True;Initial Catalog=xxx" providerName="System.Data.SqlClient" /></connectionStrings><system.web><pages><controls><add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls></pages><httpHandlers><remove verb="*" path="*.asmx"/><add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpHandlers><httpModules><add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></httpModules></system.web></configuration>
can I do it with hidden field or any other idea?
Thx