Asp – Postback issue in ASP.NET

asp.netpostback

I have an asp.net label control with its Visible property set to false. In the code-behind I'm setting its visibility to true/false based on whether the user has logged in or not. A weird behavior is that on postbacks, the code-behind executes and sets the value of the label's visibility to whatever, and then the markup executes and sets the label's visibility to false. On non-postback requests, the status set by the code-behind is not overwritten. Pardon my ignorance, but am I missing something important?

Best Answer

Get to know the page lifecycle, and when the various page events are fired by the runtime.

http://msdn.microsoft.com/en-us/library/ms178472.aspx

Also, I don't think the code is insignificant. If it were coded properly, you wouldn't be experiencing this problem. Put it up here and let us have a look.