【问题标题】:Textbox Locks up文本框锁定
【发布时间】: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
         }
}

非常感谢您的帮助

【问题讨论】:

    标签: c# html webforms


    【解决方案1】:

    因为 asp.net WebForms 中的 PostBack。 你有两个选择:

    1. 使用jquery 在客户端检查验证。
    2. 将您的控制器放入UpdatePanel

    【讨论】:

      猜你喜欢
      • 2012-01-02
      • 2010-09-20
      • 2014-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多