仅在IE上,当用户滚动自动完成结果时,会触发文本框回发。我在Chrome或FF中没有问题。
<asp:TextBox ID="txtBreakfast" ClientIDMode="Static" CssClass="headerinput" AutoPostBack="true" runat="server" OnTextChanged="txtBreakfast_TextChanged"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="txtBreakfast_AutoCompleteExtender" runat="server" UseContextKey="true" ContextKey="" Enabled="True" ServicePath="/service/service1.asmx" ServiceMethod="GetFoodNames" MinimumPrefixLength="1" CompletionSetCount="10" TargetControlID="txtBreakfast" CompletionInterval="500" CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters=";,:" ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
它应该如何工作: 用户开始输入食物,然后从扩展器div中选择食物,然后发生回发,并根据食物显示其他数据库信息。
答案 0 :(得分:0)
如果你删除
AutoPostBack="true" runat="server" OnTextChanged="txtBreakfast_TextChanged"
它有效吗?
更改文本框文本后(从下拉列表中选择一个值)触发事件OnTextChanged ..
答案 1 :(得分:0)
我刚刚使用了jquery ui,我发现没有自动完成回发的解决方案,它只是在IE中不起作用。
我在网上读到了,这就是结论
答案 2 :(得分:0)
您需要删除AutoPostBack="true"
并手动执行回发。添加一个JavaScript函数来执行PostBack,并将OnClientItemSelected
添加到AutoCompleteExtender中以使用它。
function BreakfastChanged() {
__doPostBack("txtBreakfast", "");
}
<asp:TextBox
ID="txtBreakfast"
ClientIDMode="Static"
CssClass="headerinput"
runat="server"
OnTextChanged="txtBreakfast_TextChanged">
</asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
ID="txtBreakfast_AutoCompleteExtender"
runat="server"
UseContextKey="true"
ContextKey=""
Enabled="True"
ServicePath="/service/service1.asmx"
ServiceMethod="GetFoodNames"
MinimumPrefixLength="1"
CompletionSetCount="10"
TargetControlID="txtBreakfast"
CompletionInterval="500"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";,:"
ShowOnlyCurrentWordInCompletionListItem="true"
OnClientItemSelected="BreakfastChanged">
</ajaxToolkit:AutoCompleteExtender>