I am using Ajax autocomplete method and use ServiceMethod for that but i saw the error in console that POST 401 Unauthorised
<asp:TextBox ID="txtsearch" runat="server" AutoPostBack="True" Height="22px" OnTextChanged="txtsearch_TextChanged1"></asp:TextBox>
<Ajax:AutoCompleteExtender ID="AutoCompleteExtender_search" runat="server" Enabled="True"
MinimumPrefixLength="1" ServiceMethod="GetSearch" TargetControlID="txtsearch"
UseContextKey="True" ServicePath="">
and my Service method is as follows
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static List<string> GetSearch(string prefixText, int count, string contextKey)
{
DataTable dt = new DataTable();
string constr = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("Select" + contextKey + " from tbl_emp where " + contextKey + "like @Emp + '%' group by ", con);
cmd.Parameters.AddWithValue("@Emp", prefixText);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
List<string> EmpName = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
EmpName.Add(dt.Rows[i][0].ToString());
}
return EmpName;
}
Every thing is fine and we placed Script Manager Also no error but Saw this erro In browser console Plz help me