Last post Sep 26, 2017 06:00 AM by Edward Z
Sep 25, 2017 05:36 AM|RobertH3|LINK
Trying to create a web service for auto complete extender. Saw some tutorials but can't get it to work
<ajx:AutoCompleteExtender ID="AC1" runat="server" ServiceMethod="FindItemId" MinimumPrefixLength="2" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10" TargetControlID="TextBox1" FirstRowSelected="false" ServicePath="~/FindItemId.asmx"></ajx:AutoCompleteExtender>
/// Summary description for FindItemId
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
public class FindItemId : System.Web.Services.WebService
public static List<string> GetItemId(string prefixText, int count)
using (SqlConnection conn = new SqlConnection())
conn.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = "SELECT ItemId FROM CoItems where ItemId like @SearchText + '%'";
cmd.Connection = conn;
List<string> Items = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
<asp:ServiceReference Path="~/FindItemId.asmx" />
How is it supposed to work?
Sep 25, 2017 06:43 AM|Edward Z|LINK
>> Saw some tutorials but can't get it to work
What do you mean by it did not work? Did you get any error? If you put a breakpoint on “return Items” line, did it return the expected values?
I suggest you try to follow below link.
Sep 25, 2017 01:01 PM|RobertH3|LINK
The Autocomplete Extender did not show, I watched the video but since in videos they never show you how to cross disciplines, i need it to read from a database, not a set of values they give in a video. So nothing happened, which I take that it did not work.
Sep 26, 2017 06:00 AM|Edward Z|LINK
>> I watched the video but since in videos they never show you how to cross disciplines
What do you mean by this? Did you check my link? It shared getting data from database.
>> i need it to read from a database, not a set of values they give in a video
I am wondering if you return a set of values instead of reading from database, will Autocomplete Extender show up?
I suggest you put a break point on “GetItemId” to check whether this service is called, and check Items whether it return the right values.