In ASP.NET, trying to find the assigned visibility value of a control that may be inside an invisible container
<p>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.</p>

<p>I did some searching and found the post <a href="http://stackoverflow.com/q/2005322/487909">How to get the set/real value of the Visible property in Asp.Net</a> which offered the following solution</p>

<pre><code>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});
}
</code></pre>

<p>But when I tried it, it returned an "Ambiguous Match Found" error on GetProperty.</p>

<p>Can someone point out what I'm doing wrong, or show another way of getting what I want?</p>
