Posted on: 1/30/2015 12:45:09 AM | Views : 553

I'm confused about non-static variables. We have an ASP.NET web form that tries to insert some records into a database by submitting the form to itself and if it fails, displays an error message by setting the visibility of a System.Web.UI.WebControls.Label (ErrorMessageDetail) to true.
When the user makes some changes to the form and clicks the submit button again the transaction succeeds. However, the old error message still displays! How could this be? I spent hours trying to fix the bug.
My colleague finally fixed the bug by explicitly setting ErrorMessageDetail.Visable to false.
How could this be?
Don't we get a fresh copy of all static and non-static page member variables every time we post to ourselves and display the page again? I thought that static variables were not sufficient for preserving state and this is why we have the view state feature and the session state feature.
What is even weirder is that ErrorMessageDetail is a ...

Go to the complete details ...