• <bdo id='97gIO'></bdo><ul id='97gIO'></ul>
  • <tfoot id='97gIO'></tfoot>

      1. <i id='97gIO'><tr id='97gIO'><dt id='97gIO'><q id='97gIO'><span id='97gIO'><b id='97gIO'><form id='97gIO'><ins id='97gIO'></ins><ul id='97gIO'></ul><sub id='97gIO'></sub></form><legend id='97gIO'></legend><bdo id='97gIO'><pre id='97gIO'><center id='97gIO'></center></pre></bdo></b><th id='97gIO'></th></span></q></dt></tr></i><div id='97gIO'><tfoot id='97gIO'></tfoot><dl id='97gIO'><fieldset id='97gIO'></fieldset></dl></div>

        <small id='97gIO'></small><noframes id='97gIO'>

      2. <legend id='97gIO'><style id='97gIO'><dir id='97gIO'><q id='97gIO'></q></dir></style></legend>
      3. 如何让 ASP.NET TextBox 触发它在 AJAX UpdatePanel 中触发 onTextChanged

        时间:2023-06-10

        <small id='qQGgf'></small><noframes id='qQGgf'>

          <tbody id='qQGgf'></tbody>

          • <bdo id='qQGgf'></bdo><ul id='qQGgf'></ul>

              <i id='qQGgf'><tr id='qQGgf'><dt id='qQGgf'><q id='qQGgf'><span id='qQGgf'><b id='qQGgf'><form id='qQGgf'><ins id='qQGgf'></ins><ul id='qQGgf'></ul><sub id='qQGgf'></sub></form><legend id='qQGgf'></legend><bdo id='qQGgf'><pre id='qQGgf'><center id='qQGgf'></center></pre></bdo></b><th id='qQGgf'></th></span></q></dt></tr></i><div id='qQGgf'><tfoot id='qQGgf'></tfoot><dl id='qQGgf'><fieldset id='qQGgf'></fieldset></dl></div>
            1. <legend id='qQGgf'><style id='qQGgf'><dir id='qQGgf'><q id='qQGgf'></q></dir></style></legend>
                • <tfoot id='qQGgf'></tfoot>
                  本文介绍了如何让 ASP.NET TextBox 触发它在 AJAX UpdatePanel 中触发 onTextChanged 事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图让文本框在每次击键时触发它的 onTextChanged 事件,而不是仅在失去焦点时触发.我认为添加 AsyncPostBackTrigger 可以做到这一点,但它仍然无法正常工作.我想要做的甚至可能吗?代码如下:

                  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Items.aspx.cs" MasterPageFile="~/MMPAdmin.Master" Inherits="MMPAdmin.Items" %><asp:Content ID="content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1"><asp:ScriptManager ID="sm_Main" runat="server"/><div style="left:10px;position:relative;width:100%;overflow:hidden"><asp:UpdatePanel ID="up_SearchText" runat="server"><触发器><asp:AsyncPostBackTrigger ControlID="tb_Search" EventName="TextChanged"/></触发器><内容模板><div style="position:relative;float:left"><b style="font-size:xx-large">项目</b>(<a href="Item.aspx">新增</a>)</div><div style="right:25px;position:absolute; top:30px">搜索:<asp:TextBox ID="tb_Search" runat="server" Width="200" OnTextChanged="UpdateGrid" AutoPostBack="true"/></div><br/>

                  <asp:GridView runat="server" AutoGenerateColumns="true" ID="gv_Items" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true"/></div></内容模板></asp:UpdatePanel></div></asp:内容>

                  解决方案

                  • onkeyup 使用 javascript 引发时,您需要为您的文本框控件调用 _postback() 函数.
                  • 但是,由于您的文本框位于更新面板内,因此每次用户按下某个键时都会重新渲染该文本框,从而导致光标失去焦点.
                  • 除非您将文本框从更新面板中取出,否则它将无法使用.这可能对您有用,因为更新面板往往有点慢,您可能仍然存在可用性问题.- 我建议使用自动完成组件.

                  P.S:在 asp.net 控制工具包中有一个,或者您可以使用我发现更好一点的 jquery 自动完成插件.

                  I am trying to get an textBox to fire it's onTextChanged event every time a keystroke is made rather than only firing only when it loses focus. I thought that adding the AsyncPostBackTrigger would do this but it's still not working. Is what I'm trying to do even possible? The code is below:

                  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Items.aspx.cs" MasterPageFile="~/MMPAdmin.Master" Inherits="MMPAdmin.Items" %>
                  <asp:Content ID="content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
                  <asp:ScriptManager ID="sm_Main" runat="server" />
                      <div style="left:10px;position:relative;width:100%;overflow:hidden">
                          <asp:UpdatePanel ID="up_SearchText" runat="server">
                              <Triggers>
                                   <asp:AsyncPostBackTrigger ControlID="tb_Search" EventName="TextChanged" />
                              </Triggers>
                              <ContentTemplate>
                                  <div style="position:relative;float:left">
                                      <b style="font-size:xx-large">Items</b>(<a href="Item.aspx">Add New</a>)
                                  </div>
                                  <div style="right:25px;position:absolute; top:30px">
                                      Search: <asp:TextBox ID="tb_Search" runat="server" Width="200" OnTextChanged="UpdateGrid" AutoPostBack="true" />
                                  </div>
                                  <br />
                                  <div>
                                      <asp:GridView runat="server" AutoGenerateColumns="true" ID="gv_Items" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" />
                                  </div>
                              </ContentTemplate>
                          </asp:UpdatePanel>
                      </div>
                  </asp:Content>
                  

                  解决方案

                  • You need to call the _postback() function for your textbox control when the onkeyup is raised using javascript.
                  • However, since your textbox is inside your update panel, the textbox will get re-rendered everytime the user hits a key, causing the cursor to loose focus.
                  • This will not be usable unless you get your textbox out of the the updatepanel. That may work out for you, as update panels tend to be a bit slow, you may still have usability issues. - I would suggest using an autocomplete component.

                  P.S : there is one in the asp.net control toolkit or you could use the jquery autocomplete plugin which I have found to be a bit better.

                  这篇关于如何让 ASP.NET TextBox 触发它在 AJAX UpdatePanel 中触发 onTextChanged 事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:只允许文本框中的特定字符 下一篇:如何在 Visual C# 中更改另一个窗体上的文本框中的文本?

                  相关文章

                  1. <small id='nZ2Y0'></small><noframes id='nZ2Y0'>

                    1. <i id='nZ2Y0'><tr id='nZ2Y0'><dt id='nZ2Y0'><q id='nZ2Y0'><span id='nZ2Y0'><b id='nZ2Y0'><form id='nZ2Y0'><ins id='nZ2Y0'></ins><ul id='nZ2Y0'></ul><sub id='nZ2Y0'></sub></form><legend id='nZ2Y0'></legend><bdo id='nZ2Y0'><pre id='nZ2Y0'><center id='nZ2Y0'></center></pre></bdo></b><th id='nZ2Y0'></th></span></q></dt></tr></i><div id='nZ2Y0'><tfoot id='nZ2Y0'></tfoot><dl id='nZ2Y0'><fieldset id='nZ2Y0'></fieldset></dl></div>

                      <legend id='nZ2Y0'><style id='nZ2Y0'><dir id='nZ2Y0'><q id='nZ2Y0'></q></dir></style></legend>
                      • <bdo id='nZ2Y0'></bdo><ul id='nZ2Y0'></ul>
                      <tfoot id='nZ2Y0'></tfoot>