[英]How to get the newly entered text in the TextChanged event?
I'm doing a page navigation control. 我正在做页面导航控件。 After typing a new number in text box and Enter, 在文本框中输入新的数字,然后按Enter,
void pageNoTextBox_TextChanged(object sender, EventArgs e)
The above event is called.But I am still getting the old text from the text box in the following statement 上面的事件被称为。但是我仍然从下面的语句中的文本框中获取旧文本
newPageNumber = Int32.Parse(pageNoTextBox.Text.Trim());
for example if the textbox had 1
and and I entered 12
, what I am getting is 1
in the TextChanged
event where as javascript returns new value. 例如,如果文本框有1
并且我输入12
,则在TextChanged
事件中我得到的是1
,其中javascript返回了新值。
<asp:TextBox ReadOnly="false" CssClass="txtfld_s" ForeColor="white" ID="pageNoTextBox" runat="server" Text="" AutoPostBack="true" CausesValidation="True" OnTextChanged="pageNoTextBox_TextChanged"></asp:TextBox>
This is the text box. 这是文本框。 Is there any way to get the newly entered text using C#? 有什么方法可以使用C#获取新输入的文本吗?
Well I think this will do the thing you want. 好吧,我认为这会做您想要的事情。
private void pageNoTextBox_TextChanged(object sender, EventArgs e)
{
TextBox textbox = sender as TextBox;
if(textbox != null)
{
string theText = textbox.Text;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.