asp.net - 当文本框位于 ListView 内时如何捕获 textchanged 事件?

标签 asp.net listview

我在 ListView 中有一系列文本框,其中包含员工的小时和分钟。我希望当任何文本框失去焦点时计算输入的值。我试过this exemple from the MSDM 。对于按钮和 LinkBut​​ton,我可以使用 OnItemCommand,对于 DDl 和列表框,我可以使用 OnSelectedIndexChanged

我的文本框的 Textchanged 怎么样?我没有看到他们有任何事件。从 MSDN 来看,唯一与此类似的方法是 TextBox.TextChanged Event。但该页面上说:“此 API 支持 .NET Framework 基础结构,并不打算直接从您的代码中使用。”

最佳答案

TextBoxes 位于 ItemTemplate(或 EditItemTemplate)中,不是吗?如果他们有AutoPostBack=true,一旦文本发生变化并且焦点丢失,他们就会回发。与 ListView 外部相同。

在 aspx 上:

<ItemTemplate>
  <tr runat="server">
    <td>
      <asp:TextBox OnTextChanged="TextBox1_TextChanged" AutoPostBack="true"
            ID="Textbox1" runat="Server" Text="here is text"  />
    </td>
    <td>
  </tr>
</ItemTemplate>

在代码隐藏中:

protected void TextBox1_TextChanged(object sender, EventArgs e)
{
   TextBox TextBox1 = (TextBox) sender;
}

关于asp.net - 当文本框位于 ListView 内时如何捕获 textchanged 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12117168/

相关文章:

c# - ASP .NET - 从选定的 Listview 控件行检索值?

wpf - ListView 中的多重绑定(bind)

c# - 通过.net访问openfire Java API?

c# - 我怎样才能访问 mvc4 中的成员表?

c# - 安全地实现两因素身份验证

android - ListView:textIsSelectable 和 onItemClick

javascript - 无法从 asp.net 内容页面访问 js 或 jquery 文件

c# - "The process cannot access the file because it is being used by another process"图片

android - 在自定义 ListView 中隐藏数字键盘后复选框的状态发生变化

java - ListView.setItems() 如何工作?