Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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" %>
<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 22-Feb-13 11:03am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Mistake, disregard this solution.
  Permalink  
v2
Comments
Haseeb4328 at 22-Feb-13 17:16pm
   
I Enabled it but still not working.
richcb at 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
0 Sergey Alexandrovich Kryukov 6,532
1 OriginalGriff 5,976
2 CPallini 2,473
3 Richard MacCutchan 1,687
4 Abhinav S 1,550


Advertise | Privacy | Mobile
Web04 | 2.8.140821.2 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2014
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