Autocompleteextender没有webservice无法正常工作
我已经在CP和其他地方看过很多帖子和提示,这些帖子和提示显示人们已经成功实现了AjaxControlToolkit自动完成而没有网络服务,但我无法获取页面方法。
我想我已尝试过各种方法,但无济于事。我的代码目前看起来像这样:
.aspx:
I've seen numerous posts and tips on CP and elsewhere that show people having successfully implemented the AjaxControlToolkit auto-complete without a webservice but I just can't get the page method to fire.
I think I've tried every approach out there, but to no avail. My code, at present, looks like this:
.aspx:
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePageMethods="true" </asp:ToolkitScriptManager>
<asp:TextBox runat="server" ID="tbMatterReference" />
<asp:AutoCompleteExtender ID="tbMatterReference_AutoCompleteExtender"
runat="server" DelimiterCharacters="" Enabled="True"
ServiceMethod="GetCompletionList" CompletionInterval="0" CompletionSetCount="1" ServicePath=""
TargetControlID="tbMatterReference" UseContextKey="True"></asp:AutoCompleteExtender>
aspx.cs :
aspx.cs:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string[] GetCompletionList(string prefixText, int count)
{
MatterDetailsList matters = new MatterDetailsList();
List<string> list = new List<string>();
foreach (MatterDetails matter in matters.MatterDetails)
{
list.Add(matter.code);
}
return list.ToArray<string>();
}
这样没有错误,它只是没有什么都不做后面的代码中的断点没有被击中,TextBox只是作为一个vanilla TextBox工作。
我确定我错过了一些令人眼花缭乱的东西!
There are no errors as such, it just doesn't do anything. Breakpoints in the code behind aren't hit and the TextBox just works as a vanilla TextBox.
I'm sure that I'm missing something blindingly obvious!
我是个白痴。
我的代码隐藏方法抛出异常,但是这由扩展器处理/抑制。如果错误被抛出会更好,但我真的应该发现它。
I'm an idiot.
There was an exception being thrown by my code-behind method but this gets handled/suppressed by the extender. It would be nicer if the error was thrown but I really should have spotted it.