【发布时间】:2018-04-25 12:37:24
【问题描述】:
我遇到了更新面板中的 asp.net 文本框的问题。添加或删除每个单独的字符时效果很好,但是如果我突出显示文本框中的所有文本,然后将其删除,则会发生完整的回发,而不是预期的部分回发。
为什么会这样?我没有发现任何与这个特定问题相关的东西,所以很可能我做错了什么。
示例aspx:
<asp:UpdatePanel ID="updExample" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Repeater ID="rptExample" runat="server" .... >
<ItemTemplate>
<asp:TextBox ID="txtExample" runat="server" ClientIDMode="static" Text='<%# Eval("Example") %>' OnTextChanged="txtExample_TextChanged" AutoPostBack="true"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
TextChanged 事件示例:
protected void txtExample_TextChanged(object sender, EventArgs e)
{
updExample.Update();
}
补充说明:
- 将 UpdateMode 切换为“始终”不起作用。
【问题讨论】:
-
如果为更新面板添加触发器?? link在这里学习
-
我已经在中继器 ItemDataBound 事件中执行了此操作。但是,经过考虑,ItemCreated 更适合,因此重新分配了触发器。对此进行调整后,它现在似乎可以工作了,谢谢。
标签: c# asp.net textbox updatepanel