Reputation: 1169
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.
Upvotes: 1
Views: 4023
Reputation: 1169
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.
Upvotes: 2
Reputation: 1251
For me the answer was higher up in the web service code. In addition to adding [System.Web.Script.Services.ScriptMethod] above the method, there is a line that has to be uncommented. Change:
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
to
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
Upvotes: 0
Reputation: 6055
One of the problem can be that you didn't enable PageMethods feature of the ScriptManager (ToolkitScriptManager) control.
So, ensure that you have code similar to this in you master or aspx page:
<cc1:ToolkitScriptManager ID="scriptManager" runat="server" EnablePartialRendering="true"
EnablePageMethods="true">
Upvotes: 0