ajax AutoCompleteExtender not working in user control (.ascx) but when use directly on aspx page its working perfectly. Please give me suggetion.
<asp:TextBox ID="txtSearchProject" runat="server" CssClass="input col-lg-4" type="text" placeholder="Type Location or Project/Society or Keyword"></asp:TextBox>
<cc1:AutoCompleteExtender ID = "Act_SearchProject" runat = "server" TargetControlID = "txtSearchProject" MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="100" ServiceMethod="GetLocality_Project" > </cc1:AutoCompleteExtender>
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetLocality_Project(string prefixText)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ToString());
string str = "SELECT DISTINCT TOP 12 Location FROM tbl_location WHERE Location LIKE '" + prefixText + "%' AND LocationID IN(select LocationID from vw_project )";
con.Open();
SqlCommand com = new SqlCommand(str, con);
SqlDataReader dr = com.ExecuteReader();
int i = 0;
List<string> AlNames = new List<string>();
if (dr.HasRows)
{
while (dr.Read())
{
string StrTemp = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(dr["Location"].ToString().ToLower());
AlNames.Add(StrTemp);
i++;
}
}
return AlNames;
}