2017-09-22 45 views
0

我正在使用Visual Studio 2015 - ASP DOTNET C#和WebForms 我已經編寫了一個程序,並且它的一部分需要用戶通過文本框輸入一個數字,當用戶列出事件觸發成功時並檢索填充表單上所有相關字段的記錄。Textbox鎖定

有時用戶可以輸入另一個數字,它會觸發,有時文本框會鎖定,就好像只讀是真的,它不會讓你刪除文本,輸入更多的文本等,你必須點擊然後在頁面上隨機按鈕,然後清除問題。我非常難以理解它爲什麼這樣做。

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 
     } 
} 

非常感謝您的幫助

回答

0

因爲回傳的在asp.net的WebForms。 您有兩種選擇:

  1. 檢查客戶端的驗證與jquery
  2. 把你的控制器放在UpdatePanel