I am Very much new to C Sharp. In My project I am designing a search page where I have Text Box with AJAX Control Auto Extender, I am Using a Web Service to fill the Text Box (This is the first time I am Using Web Service I don’t know to what the Web Service will be used) when the User Types the Word in the Text Box. I had specified everything correctly, when I run my Program and type the Word there is no response.
This Question may look like a Duplicate Question but not I had googled out many time seen many blogs worked out with the Examples shown there but No Result. Somebody help me please,
My Web Service Code is,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using SubSonic;
using DataAccessLayer;
using System.Web.Configuration;
using System.Web.Services.Protocols;
using System.Xml.Linq;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class Search : System.Web.Services.WebService
{
public void Autocomplete()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[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 QueryString;
QueryString = System.Configuration.ConfigurationManager.ConnectionStrings ["IUMSNXG"].ToString();
using (SqlConnection obj_SqlConnection = new SqlConnection(QueryString))
{
using (SqlCommand obj_Sqlcommand = new SqlCommand())
{
obj_Sqlcommand.CommandType = CommandType.StoredProcedure;
obj_Sqlcommand.CommandText = "LRS_SP_CBFM_Sel";
obj_Sqlcommand.Connection = obj_SqlConnection;
obj_SqlConnection.Open();
obj_Sqlcommand.Parameters.AddWithValue("@animalCode", strName);
SqlDataAdapter dt = new SqlDataAdapter(obj_Sqlcommand);
DataSet ds=new DataSet();
dt.Fill(ds);
obj_SqlConnection.Close();
return ds.Tables[0];
}
}
}
}
My AJAX Tool Script Manager is
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/Search.asmx" />
</Services>
</asp:ToolkitScriptManager>
My Text Box and Auto Complete Extender is,
<Anthem:TextBox ID="srchtxt" runat="server" AutoUpdateAfterCallBack="true"
Height="19px" Width="200px"></Anthem:TextBox>
<asp:AutoCompleteExtender ID="srchtxt_AutoCompleteExtender" runat="server"
CompletionInterval="100" DelimiterCharacters="" Enabled="True"
ServicePath="~/Search.asmx"
TargetControlID="srchtxt" UseContextKey="True"
ServiceMethod="GetCompletionList">
</asp:AutoCompleteExtender>