TextChanged Event Issue RRS feed

  • Question

  • I'm writing a Web Application using Visual Studio 2015, have finished my project but have a slight issue with one of my text boxes on a couple of the screens, on the TextChanged Event, the user enters a valid number, upon tabbing out it validates the number then retrieves the record from the database. The first time through no issues record is retrieved. Second time no issues. It's at this point that the Textbox locks up, I have to either click a random button on the page or select a random entry from a dropdown, this then frees up the textbox for input. Upon tabbing out it locks up again.

    I've got an update panel, textboxes, a grid to display the results and dropdowns to filter the result set. The TextChanged event has the following code

    Any help appreciated

    protected void txtAsset_TextChanged(object sender, EventArgs e)
        lblSuccessful.Text = string.Empty;
        string input = txtAsset.Text;
          if (!Regex.IsMatch(input, @"^[0-9]\d*"))
             lblSuccessful.CssClass = "ErrorMessage";
             lblSuccessful.Text = "You have input invalid criteria into the Asset field, please check";
             txtAsset.Text = string.Empty;
             //Retrieve Record Routine

    • Moved by CoolDadTx Monday, September 25, 2017 1:58 PM ASP.NET related
    Monday, September 25, 2017 7:12 AM

All replies

  • Does it work if you let the user to check and fix the suggested Asset field? (I. e. do not remove the text and do not set the focus).

    By the way, see this place too: https://forums.asp.net/.

    Monday, September 25, 2017 7:30 AM
  • Hi

    I removed the set focus, no change at all, still kept locking up the text box

    If  I add a image button, remove the code from the text box and have an onclick event with the button, no issues at all. I can type in values all the time.

    Monday, September 25, 2017 7:43 AM
  • Quick Observation

    If I remove the focus and add it to the page load event with a !postback element, the screen still locks up.

    My imgbtn, if I leave that on the screen with the same code that the TextChanged executes, the form can take input from textbox and button click, no issues at all

    When I removed the imgbtn after several inputs on the textbox it locks up again, my workaround is to leave the imgbtn showing on the screen.

    Monday, September 25, 2017 8:18 AM
  • Please post questions related to ASP.NET in the ASP.NET forums.
    Monday, September 25, 2017 1:58 PM