This is my aspx File
<asp:ImageButton ID="frumgrp_srch_imgbtn" runat="server" ImageUrl="~/images/search.png" />
<br />
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="frumgrp_srch_txt"
EnableCaching="true"
BehaviorID="AutoCompleteCities"
ServiceMethod="GetCities" ServicePath="~/AutoComplete.asmx" MinimumPrefixLength="1" CompletionSetCount="5"
FirstRowSelected="true">
</asp:AutoCompleteExtender>
This Is My Cs File
using System;
using System;
using System.Collections.Generic;
using System.Web.Services;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
[WebService]
[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;
}
DataTable dt = GetRecords(prefixText);
List<string> items = new List<string>(count);
for (int i = 0; i < dt.Rows.Count; i++)
{
string strName = dt.Rows[i][0].ToString();
items.Add(strName);
}
return items.ToArray();
}
public DataTable GetRecords(string strName)
{
string strConn = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.AddWithValue("@Name", strName);
cmd.CommandText = "Select Name from Test where Name like '%'+@Name+'%'";
DataSet objDs = new DataSet();
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = cmd;
con.Open();
dAdapter.Fill(objDs);
con.Close();
return objDs.Tables[0];
}
}
This is My asmx File
<![CDATA[<%@ WebService Language="C#" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %>
I'm not able to execute this code. Infact the webservice it self is not getting called. Can Anyone help. Your help will be a great relief to me.
Eagerly Waiting For The Solution
Thanks in advance