Autocomplete extender not working..i dont know the solution,here is code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srimathiparthasarathy
    New Member
    • Feb 2010
    • 18

    #1

    Autocomplete extender not working..i dont know the solution,here is code

    I am using Ajax autoextender control to textbox for displaying cities name...
    But when i run my project i have to type all the characters in the text box
    Autocomplete not working...i have refer may website..am using code behind c#.net


    my webservice\\


    Code:
    using System;
    using System.Collections.Generic;
    using System.Web.Services;
    using System.Data;
    
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class AutoComplete : WebService
    {
        public AutoComplete()
        {
        }
    
        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            if (count == 0)
            {
                count = 10;
            }
    
            if (prefixText.Equals("xyz"))
            {
                return new string[0];
            }
    
            List<string> items = new List<string>(count);
    
            DataSet ds = new DataSet();        
            ds.ReadXml(Server.MapPath(@"Xml\Cities.xml"));
            foreach (DataRow drow in ds.Tables[0].Rows)
            {
                int a = 1;
                if (Int32.TryParse(prefixText,out a))
                {
                    drow["district"] = drow["pincode"] + "," + drow["city"] + ","+drow["district"] + "," + drow["state"]  ;
                }
                else
                {
                    drow["district"] = drow["district"] + "," + drow["city"] + "," + drow["pincode"] + "," + drow["state"];
                }
            }
    
            string filter = string.Format("district like '{0}%'", prefixText);
            ds.Tables[0].DefaultView.RowFilter = filter;
            DataTable dt = ds.Tables[0].DefaultView.ToTable();
            for (int i = 0; i <= dt.Rows.Count - 1; i++)
            {
                items.Add(dt.Rows[i]["district"].ToString());
            }
    
            return items.ToArray();
        }
    }


    ///////////////My asp.net source for text box and ajaxtoolkit


    Code:
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    
    
    <asp:TextBox ID="txtAutoComplete" runat="server" Width="223" AutoComplete="on" CssClass="RealtorsTextBoxText"
                                                        ValidationGroup="Property_Buy_Search" 
                                                        ontextchanged="txtAutoComplete_TextChanged"></asp:TextBox>
                                                    <ajaxToolkit:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteEx" ID="autoComplete1"
                                                        TargetControlID="txtAutoComplete" ServicePath="~/AutoComplete.asmx" ServiceMethod="GetCompletionList"
                                                        MinimumPrefixLength="2" CompletionInterval="1000" EnableCaching="true" CompletionSetCount="5"
                                                        CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem"
                                                        CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters=";, :">
                                                    </ajaxToolkit:AutoCompleteExtender>

    Help me

    thank u
    Last edited by tlhintoq; Mar 31 '10, 08:37 AM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

    Comment

    • srimathiparthasarathy
      New Member
      • Feb 2010
      • 18

      #3
      dont u know autocomplete extender.i am not asking you about code tag.i know that.

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        If you know about using the code tags then please do. It makes your posts much easier to follow. If posts are easier to read then it is more likely you will get the help you are looking for.

        I know nothing about the extender, or ajax or ASP. I am a C#, Windows Forms guy that mostly does applications that interface to, and directly control other hardware.

        Comment

        Working...