troubleshooting Question

ASP.NET - How to flash the background of text boxes after saving to indicate something happened.

Avatar of Siv
SivFlag for United Kingdom of Great Britain and Northern Ireland asked on
ASP.NET.NET ProgrammingC#
14 Comments1 Solution159 ViewsLast Modified:
I am working on an asp.net project using c# as the language used and want to emulate what I have always done in desktop applications which is when a user saves a record and the save is successful, I clear the text boxes of input, flash the background colour of the cleaned boxes to a non-white (usually use Powder Blue or a similar pale colour) and then reload the saved data to show that the information has been stored successfully. Then return the BackColor to white again.

With web pages I would like to do the same thing but without generating masses of web traffic, so maybe there is a neat way of doing  that?  

At the moment I am saving the record then calling my PopulateScreen routine that does a call to my ClearScreen routine and then populates the text boxes from the database again.  My ClearScreen routine looks like this:

      private void ClearScreen()
      {
            try
            {
                  txtEmailAddress.BackColor = System.Drawing.Color.PowderBlue;
                  txtFirstName.BackColor = System.Drawing.Color.PowderBlue;
                  txtSurname.BackColor = System.Drawing.Color.PowderBlue;
                  cboUserType.BackColor = System.Drawing.Color.PowderBlue;
                  txtPassword.BackColor = System.Drawing.Color.PowderBlue;

                  txtEmailAddress.Text = "";
                  txtFirstName.Text = "";
                  txtSurname.Text  = "";
                  cboUserType.SelectedValue = "0"; //First entry in list
                  txtPassword.Text = "";

                  System.Threading.Thread.Sleep(500);

                  txtEmailAddress.BackColor = System.Drawing.Color.White;
                  txtFirstName.BackColor = System.Drawing.Color.White;
                  txtSurname.BackColor = System.Drawing.Color.White;
                  cboUserType.BackColor = System.Drawing.Color.White;
                  txtPassword.BackColor = System.Drawing.Color.White;

            }
            catch(Exception ex)
            {
                  Common.PEH("PopulateScreen", "frm4-02", ex.Message);
            }
      }

When I run this I don't see the BackColor change it's as if the half second delay doesn't do anything, as I don't see the BackColor go blue and I am concerned that using Thread.Sleep is probably a ham fisted way of doing it.

I have found ways of throwing up an alert box confirming that the record is saved,  but I'd rather not force the user to have to click the dialog every time they save.

Any help with this appreciated.

Siv
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros