简体   繁体   English

asp.net OnTextChanged无法触发

[英]asp.net OnTextChanged not firing

I've got a few OnTextChanged events which aren't firing. 我有一些不会触发的OnTextChanged事件。 The PostBack is set to true, and they're being changed (with the current date/time) from other bits in the asp.net / java code. PostBack设置为true,并且它们已与asp.net/java代码中的其他位(使用当前日期/时间)进行了更改。 Their values are being changed, so the events should fire but they're not: 它们的值正在更改,因此事件应该触发,但它们不是:

<asp:TextBox ID="lblRoute" runat="server" AutoPostBack="true" OnTextChanged="btnRoute_Click" BorderColor="White" BorderStyle="None" ForeColor="White" Width="5px"></asp:TextBox>

As I mention, the value of this textbox is changing (and it is visible, but made to look like it isn't - it exists purely to fire it's event) but the event isn't being fired. 正如我所提到的,此文本框的值正在更改(它是可见的,但看起来好像不是-它的存在纯粹是为了触发事件),但事件并未触发。

EDIT - just to fill in some more blanks, a user presses a button in this manner: 编辑-只是为了填补更多空白,用户以这种方式按下按钮:

<button id="btnRoute" onclick="GetRoute(); return false;" runat="server" style="width: 30%">Route</button>

The button calls this, eventually (as I mention, this is being called as the label is being changed): 该按钮最终将调用此命令(正如我提到的,这是在更改标签时被调用的):

document.getElementById("lblRoute").value = Date.now();

Which changes the label lblRoute, which should fire our event (and yes, the called function does exist). 这将更改标签lblRoute,这触发我们的事件(是的,确实存在被调用的函数)。 So far it looks like I may need to change the focus, as others have said, after the label has been changed in order to fire it. 到目前为止,就像其他人所说的一样,在更改标签后,我可能需要更改焦点才能触发它。 Any ideas how I'd do that? 有什么想法我会怎么做吗?

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.textchanged(v=vs.110).aspx : http://msdn.microsoft.com/zh-CN/library/system.web.ui.webcontrols.textbox.textchanged(v=vs.110).aspx

The TextChanged event is raised when the content of the text box changes between posts to the server. 当在服务器的帖子之间更改文本框的内容时,将引发TextChanged事件。

The page will not post back immediately after the text is changed, but it will post back when the textbox loses focus. 更改文本后,该页面不会立即回发,但是当文本框失去焦点时它将回发。

仅当您的文本框失去焦点时才触发asp:TextBox的' OnTextChanged '事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM