Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Reader,

Following is my web service:

[WebService(Namespace = "http://tempuri.org/")]
   [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

   [System.Web.Script.Services.ScriptService()]
   [System.ComponentModel.ToolboxItem(false)]

   public class WebService1 : System.Web.Services.WebService
   {

       [WebMethod]
       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");
           con.Open();
           string strQuery = "select Source from Reservation where Source like '" + prefixText + "%'";
           DataSet ds = new DataSet();
           SqlDataAdapter da = new SqlDataAdapter(strQuery, con);
           da.Fill(ds);
           con.Close();
           List<string> cityList = new List<string>();
           for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
           {
               cityList.Add(ds.Tables[0].Rows[i][0].ToString());
           }
           con.Close();
           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" %>

XML
<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" >
 </ac:AutoCompleteExtender>


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.

Regards,
Posted

Mistake, disregard this solution.
 
Share this answer
 
v2
Comments
Haseeb4328 22-Feb-13 17:16pm    
I Enabled it but still not working.
Richard C Bishop 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900