In ASP.NET, trying to find the assigned visibility value of a control that may be inside an invisible container -
i trying find out whether particular control on asp.net page has had it's "visible" property assign true or false. problem visible property crawl list of parents , if of them show invisible, queried control show invisible. need know control has been set to.
i did searching , found post how set/real value of visible property in asp.net offered 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 tried it, returned "ambiguous match found" error on getproperty.
can point out i'm doing wrong, or show way of getting want?
i had same problem (two years later). answer wrote in topic refer to:
in case tries jørn schou-rode's code working in vb.net, here code works me. when translate code in vb, "ambiguous match found" exception, because there 3 flavors of flags "item" property.
<extension()> public function getlocalvisible(ctl control) boolean dim flags object = gettype(control).getfield("flags", bindingflags.instance or bindingflags.nonpublic).getvalue(ctl) dim infos propertyinfo() = flags.gettype().getproperties(bindingflags.instance or bindingflags.nonpublic) each info propertyinfo in infos if info.name = "item" andalso info.propertytype.name = "boolean" return not cbool(info.getvalue(flags, new object() {&h10})) end if next return ctl.visible end function
Comments
Post a Comment