CODE OF AUTOCOMPLETE AJAX CONTROL IN ASP.NET
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
SqlConnection con = new SqlConnection("Data Source=ANIL-PC;Initial Catalog=anil;User ID=sa;Password=anil");
con.Open();
SqlCommand cmd = new SqlCommand("select * from test Where name LIKE '" + prefixText + "%' order by name", con);
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
List<string> li = new List<string>();
while (dr.Read())
{
li.Add(dr["name"].ToString());
}
return li.ToArray();
}
After that set SERVICE METHOD PROPERTIES NAME OF METHOD:- GetCompletionList
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
SqlConnection con = new SqlConnection("Data Source=ANIL-PC;Initial Catalog=anil;User ID=sa;Password=anil");
con.Open();
SqlCommand cmd = new SqlCommand("select * from test Where name LIKE '" + prefixText + "%' order by name", con);
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
List<string> li = new List<string>();
while (dr.Read())
{
li.Add(dr["name"].ToString());
}
return li.ToArray();
}
After that set SERVICE METHOD PROPERTIES NAME OF METHOD:- GetCompletionList
No comments:
Post a Comment