我已经查看了谷歌给我的所有答案,但它没有帮助我的问题抱歉。 (如果我写标题,还有Stackoverflow给我的那些)......
它位于<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>
这个<asp:Table>
周围也是一个Updatepanel。
我的Servicemethode应该没问题:
[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));
}
它没有给我任何错误,它只是没有激活ServiceMethode。
答案 0 :(得分:1)
问题出在问题的声明中:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] SelectAllManufacturer(string prefixText, int count)
我将其改为静态方法
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string[] SelectAllManufacturer(string prefixText, int count)
并且有效。
答案 1 :(得分:0)
其中一个问题可能是您没有启用ScriptManager(ToolkitScriptManager)控件的PageMethods功能。
因此,请确保您在master或aspx页面中具有与此类似的代码:
<cc1:ToolkitScriptManager ID="scriptManager" runat="server" EnablePartialRendering="true"
EnablePageMethods="true">
答案 2 :(得分:0)
对我而言,网络服务代码中的答案更高。除了在方法上方添加[System.Web.Script.Services.ScriptMethod]之外,还有一行必须取消注释。变化:
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
到
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]