[英]Textbox textchange didn't work in asp.net c#
I have TextBox
in my popup page, what i need to do, is to check if the TextBox
in the popup contains text for example TextBox.Text.Equals("Admin");
我在弹出页面中有
TextBox
,我需要做的是检查弹出窗口中的TextBox
是否包含文本,例如TextBox.Text.Equals("Admin");
here is the TextBox
definition: 这是
TextBox
定义:
<asp:TextBox ID="TextBox1" runat="server" Height="35px"
ontextchanged="TextBox1_TextChanged" AutoPostBack="true"
style="text-align: right; font-size: x-large" Width="200px">
</asp:TextBox>
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if(TextBox1.Text.Equals("Admin"))
{
Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "closePage", "window.onunload = CloseWindow();");
}
}
the function of TextBox1_TextChanged
didn't fetch when the text is changed. 更改文本时未获取
TextBox1_TextChanged
的功能。
what i need to do, is to close the window when some text is entered, can anyone help me and/or suggest any other solution to solve this problem ? 我需要做的是在输入一些文本时关闭窗口,任何人都可以帮助我和/或建议其他解决方案来解决此问题吗? I dont need to press any button to close the window
我不需要按任何按钮来关闭窗口
thank you so much 非常感谢
I think the text changed event should be handled client side. 我认为文本更改事件应在客户端处理。 The text is a very volatile value, imagine what would it mean to go to server side whenever you press a key.
文本是一个非常不稳定的值,想像一下每当您按下一个键时转到服务器端将意味着什么。 The performance would be very bad.
性能会很差。
The TextChanged Event of textbox is fired only when you change the content of the textbox and move the cursor out of the control. 仅当您更改文本框的内容并将光标移出控件时,才会触发文本框的TextChanged事件。 If your text is entered to the textbox by card reader the cursor will remain inside the textbox.
如果通过读卡器将文本输入文本框,则光标将停留在文本框内。 After entering the text try clicking outside the textbox or press Enter or Tab and check your TextChanged Event is fired or not.
输入文本后,请尝试在文本框外单击,或者按Enter或Tab,然后检查是否触发了TextChanged事件。 if the event fired, make sure that textbox text is not cleared in your Page_Load event.
如果触发了该事件,请确保未在Page_Load事件中清除文本框文本。 You know the use of IsPostBack.
您知道IsPostBack的用法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.