Reputation: 11403
Q:
I have a panel the visibility = false in the .aspx
file ,at some point in my code i set the visibility = true.but the problem is: when i trace the code i find the visible property still equal false ,although i set it to true .
My panel name is :pnl_DetailsGeneral
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedValue == "2")
{
drp_Week.Enabled = false;
gv_Details.Visible = false;
panel_rmv.Visible = false;
pnl_DetailsGeneral.Visible = true;//Here when i put a break point and after setting visible to true i find `pnl_DetailsGeneral.Visible = false`
gv_DetailsGeneral.Visible = true;
BindGridGeneral();
}
else if (RadioButtonList1.SelectedValue == "1")
{
drp_Week.Enabled = true;
gv_Details.Visible = true;
gv_DetailsGeneral.Visible = false;
pnl_DetailsGeneral.Visible = false;
if (drp_Week.SelectedValue != "-1")
{
BindGrid();
}
}
}
what may cause this problem?
Upvotes: 4
Views: 687
Reputation: 10680
A possible explanation is implicit visibility through the control hierarchy.
For instance, if you have a placeholder than contains other controls, and the placeholder has visible set to false, all of it's child controls will also have Visible set the false, even if you set the property explicitly yourself.
Upvotes: 1
Reputation: 124726
I believe the Control.Visible
property returns false if any parent has Visible = false.
Upvotes: 1
Reputation: 39309
The Visible property has a special property: when you read the value it not only reports on the control itself but also on it's parent. The value you get is the "real" visibility.
So apparently the parent of your control is still invisible!
When you set the parent to Visible, your control will become visible also.
Upvotes: 4