I am trying to find out whether a particular control on an asp.net page has had it's "Visible" property assign to true or false. The problem is that the visible property crawl up the list of parents and if any of them show as invisible, the queried control will also show as invisible. I need to know what the control itself has been set to.
I did some searching and found the post How to get the set/real value of the Visible property in Asp.Net which offered the following solution
public static bool LocalVisible(this Control control){
var flags = typeof (Control)
.GetField("flags", BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(control);
return ! (bool) flags.GetType()
.GetProperty("Item", BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(flags, new object[] {0x10});
}
But when I tried it, it returned an "Ambiguous Match Found" error on GetProperty.
Can someone point out what I'm doing wrong, or show another way of getting what I want?