Click here to Skip to main content
12,954,522 members (54,981 online)
Rate this:
Please Sign up or sign in to vote.
Dear Reader,

Following is my web service:

 [WebService(Namespace = "")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class WebService1 : System.Web.Services.WebService
        public string[] GetCities(string prefixText)
            SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:Database.mdf;Integrated Security=True;MultipleActiveResultSets=True;Connect Timeout=30;Application Name=EntityFramework");
            string strQuery = "select Source from Reservation where Source like '" + prefixText + "%'";
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(strQuery, con);
            List<string> cityList = new List<string>();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            return cityList.ToArray();

The above service is working fine. I have tested in browser. It displays the expected output. Following is my code in aspx file:

<%@ Register TagPrefix="ac" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods = "true" ></asp:ScriptManager>
  <asp:TextBox ID="txtCity" runat="server" AutoCompleteType="Disabled"></asp:TextBox>
    <ac:AutoCompleteExtender ID="AutoCompleteExtender1"
       BehaviorID="AutoCompleteCities" TargetControlID="txtCity"
       ServiceMethod="GetCities" ServicePath="WebService1.asmx" MinimumPrefixLength="1"
        CompletionSetCount="10" CompletionInterval="100" EnableCaching="false"
       runat="server" FirstRowSelected = "false" >

I don't know why the above code is not working. There is no such error but the text box doesn't show the autocomplete data generated from web method.

Please help me to solve this problem I will be very thankful to you.

Posted 22-Feb-13 11:03am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Mistake, disregard this solution.
Haseeb4328 22-Feb-13 17:16pm
I Enabled it but still not working.
richcb 22-Feb-13 17:18pm
That was my mistake, I think you want it Disabled. I apologize. I am still researching this further.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,539
CHill60 3,490
Maciej Los 3,153
ppolymorphe 2,030
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100