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
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.