Ok, I have a usercontrol on my page.
On the page, the visible property is set to false.
On the OnPreRender event, I set the visible property to true.
It runs the line of code, but does not actually change anything. (so visible remains at false)
This exact same method works across every other control, and there is nothing special about this control.
Any ideas??
Check for the visible property on any controls containing this control.
Setting Visible=True does not mean that Visible==True, it will still return False if a parent control is False.
Other than that though, you may need to post some examples of your code in order for anyone to help track down what the problem may be.
I faced the same problem and... yes the problem is the parents not be visible. So I made this little peace of code to solve the problem:
public static void ForceVisibleState(Control control, bool visible)
{
if (!visible)
{
control.Visible = false;
}
else
{
// Must set all parents to 'visible = true'
List<Control> parents = new List<Control>();
while (control != null &&
!control.Visible)
{
parents.Insert(0, control);
control = control.Parent;
}
foreach(Control parent in parents)
{
parent.Visible = true;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With