Search code examples
c#asp.netajaxcontroltoolkit

AutoCompleteExtender not firing


i allready looked through all the answers google gave me, but it didnt help for my problem sorry. (Also the ones Stackoverflow gives me if i write the title)... It is inside a <asp:Table>

<asp:TableCell>
    <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UP3">
        <ContentTemplate>
            <asp:DropDownList runat="server" ID="SupplierDDL" Visible="false">
            </asp:DropDownList>
            <asp:TextBox runat="server" AutoPostBack="true" ID="tbSupplier">             
            </asp:TextBox>
            <cc1:AutoCompleteExtender runat="server" ID="AutoCompleteExtender1" TargetControlID="tbSupplier" BehaviorID="skldjfa"
             MinimumPrefixLength="2" EnableCaching="true" ServiceMethod="SelectAllManufacturer">
            </cc1:AutoCompleteExtender>
            <asp:HiddenField runat="server" ID="hfSupplier" /
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:TableCell>

Arround this <asp:Table> is also a Updatepanel.

my Servicemethode should be fine:

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] SelectAllManufacturer(string prefixText, int count)
{
    ArrayList filteredList = new ArrayList();
    OracleConnection oracon = GlobalFunctions.DatabaseConnection();
    OracleDataReader oradr;
    oracon.Open();
    OracleCommand oracom = new OracleCommand(Classes.SQL.SQL4global.selectSupplierBySearchString(prefixText.ToLower()), oracon);
    oradr = oracom.ExecuteReader();
    if (oradr.HasRows == true)
    {
        while (oradr.Read())
        {
                filteredList.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(
                    Convert.ToString(oradr["companyname"]) + " ** " +
                Convert.ToString(oradr["street"]) + " * " + Convert.ToString(oradr["postalcode"]) + " * " + Convert.ToString(oradr["city"]) + " * " + Convert.ToString(oradr["land"]),
                Convert.ToString(oradr["ID_Supplier"])));
        }
    }
    oradr.Close();
    oracon.Close();
    return (string[])filteredList.ToArray(typeof(string));

}

It gives me no error, it is just not activating the ServiceMethode.


Solution

  • The problem was just in the declaration of the methode:

    [System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public string[] SelectAllManufacturer(string prefixText, int count)
    

    I changed it into a static methode

    [System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public static string[] SelectAllManufacturer(string prefixText, int count)
    

    and it worked.