The property has the same value after setting it.

IN:

I have a visibility = false panel in an .aspx file, at some point in my code I set visibility = true.but the problem is : when I track the code that I find the visible property is still false, although I set it to true. My panel name: 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 can cause this problem?

+4
source share
3 answers

The Visible property has a special property: when you read a value, it not only reports about this control itself, but also about its parent. The value you get is "real" visibility.

Apparently, the parent element of your control is still invisible!

When you set the parent to Visible, your control will also become visible.

+4
source

I believe that the Control.Visible property returns false if any parent has Visible = false.

+1
source

A possible explanation is implicit visibility through the management hierarchy.

For example, if you have a placeholder that contains other controls, and the replacement object is false, all its children will also have Visible, set to false, even if you set the property yourself.

+1
source

All Articles