【问题标题】:ASP.NET jQuery - Bound ControlsASP.NET jQuery - 绑定控件
【发布时间】:2010-09-25 08:06:59
【问题描述】:

我想将 jQuery 与包含文本框的 GridView 一起使用,但我不知道如何为所选行上的每个文本框注册事件侦听器。我在想我可以在 GridView 的 Unload 事件中使用 StingBuilder 做一些事情,但我无法让它工作。

【问题讨论】:

    标签: asp.net jquery gridview autocomplete


    【解决方案1】:

    为什么不给每个 TextBox 添加一个 CSS 类并使用 jQuery 选择器来查找它们?

    <asp:GridView runat="server">
      <Columns>
        <asp:BoundField ControlStyle-CssClass="someclass" DataField="xxx" />
      </Columns>
    </asp:GridView>
    

    那你应该可以...

    $().ready(function() {
      $(".someclass").function() {
       //do something interesting
      }
    });
    

    【讨论】:

      【解决方案2】:

      如果您有很多文本框(听起来像您这样做),最好将事件委托给某个父容器,而不是附加大量事件(事件委托) 开始阅读here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多