【问题标题】:AutoCompleteExtender Causes Postback when scrolling滚动时 AutoCompleteExtender 导致回发
【发布时间】:2013-07-19 06:22:44
【问题描述】:

仅在 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 中选择食物,然后发生回发,并导致根据食物显示额外的数据库信息。

【问题讨论】:

    标签: c# asp.net .net autocompleteextender


    【解决方案1】:

    如果你删除

    AutoPostBack="true" runat="server" OnTextChanged="txtBreakfast_TextChanged"
    

    有效吗?

    文本框文本更改后(您从下拉列表中选择一个值)触发事件 OnTextChanged..

    【讨论】:

      【解决方案2】:

      您需要删除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>
      

      【讨论】:

        【解决方案3】:

        我刚刚使用了 jquery ui,我没有找到在自动完成上进行回发的解决方案,它在 IE 中不起作用。

        我在网上看了,这就是结论

        【讨论】:

          猜你喜欢
          • 2011-02-28
          • 1970-01-01
          • 1970-01-01
          • 2011-11-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-04-17
          • 1970-01-01
          相关资源
          最近更新 更多