I’m having the weirdest problem.
I have two PlaceHolders in a Master Page; one contains controls for users who are logged-out, and the other for users who are logged-in.
They are:
plhLoggedOut
plhLoggedIn
During my Page_Load (of the Master Page), I set their visibility like so:
//LOGGED-IN? plhLoggedOut.Visible = (app.UserID == 0); plhLoggedIn.Visible = (app.UserID != 0);
However, the contents of BOTH PlaceHolders are still being rendered.
I’m even writing their visibility to a status message, and that status message confirms that only one is visible at any given time. e.g.,
plhLoggedOut.Visible == True; plhLoggedIn.Visible == False
Any ideas how this could happen (and how to fix it)?
Thanks very much,
Michael
I just removed the old PlaceHolders and created two new ones with different IDs. Then it started working.
I vaguely remember having weird behaviors like that before, where for some reason the code-behind and the markup are disconnected. That might happen because I don’t use the visual designer, and write the .NET tags and the designer.cs file by hand.
FYI, slolife, I just tested it and visibility doesn’t get passed down like that from parent controls to child controls. You can nest a hidden control that remains hidden even if you set its container’s visibility to true.
Thanks, everyone,
Michael