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\\
///////////////My asp.net source for text box and ajaxtoolkit
Help me
thank u
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
Comment