i want to try and suugest list of company from sql server. in a normal web form , the code works but using in the master page it does not work.
Below is the code
<asp:TextBox ID="TextBoxSearchCompany" class="form-control" placeholder="Search company..." runat="server"/>
<asp:AutoCompleteExtender
ID="txtName_AutoCompleteExtender"
runat="server"
DelimiterCharacters=""
Enabled="True"
ServicePath ="~/AutoComplete.asmx"
ServiceMethod="GetCompletionList"
TargetControlID="TextBoxSearchCompany"
MinimumPrefixLength="2"
CompletionInterval="10"
EnableCaching="true"
CompletionSetCount="3"
ContextKey="false">
</asp:AutoCompleteExtender>
then the webservice signature is
[WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
string connectionString = ConnectionString.GetConStr();
SqlConnection conn = new SqlConnection(connectionString);
// Try to use parameterized inline query/sp to protect sql injection
SqlCommand cmd = new SqlCommand("SELECT TOP " + count + " company FROM [vwCompanyLookup] WHERE company LIKE '" + prefixText + "%'", conn);
SqlDataReader oReader;
conn.Open();
List<string> CompletionSet = new List<string>();
oReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (oReader.Read())
CompletionSet.Add(oReader["company"].ToString());
return CompletionSet.ToArray();
}
I added the following Ajax reference
<asp:ToolkitScriptManager EnablePageMethods="true" ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
But when i run the app nothing shows.
what is wrong with my code ?