【发布时间】:2017-09-25 02:11:41
【问题描述】:
我正在使用 Visual Studio 2015 - ASP DOTNET C# 和 WebForms 我编写了一个程序,其中的一部分要求用户通过文本框输入一个数字,当用户将事件成功触发并检索填充表单上所有相关字段的记录时。
有时用户可以输入另一个数字并触发,有时文本框会锁定,好像只读为真,它不允许您删除文本,输入更多文本等,您必须单击随机页面上的按钮,然后清除问题。我很困惑为什么要这样做。
protected void txtAsset_TextChanged(object sender, EventArgs e)
{
//Validate text input
lblSuccessful.Text = string.Empty;
txtAsset.Focus();
string input = txtAsset.Text;
if (!Regex.IsMatch(input, @"^[0-9]\d*"))
{
lblSuccessful.CssClass = "ErrorMessage";
lblSuccessful.Text = "You have input invalid criteria";
txtAsset.Text = string.Empty;
txtAsset.Focus();
}
else
{
Execute Retrieval of record code
}
}
非常感谢您的帮助
【问题讨论】: