Thanks for Derek's informative inputs.
Hi Hugh,
As for accessing class instance's certian members (Property , field or
method, attributes...) without explictily cast them to their actual Class
reference, currently the System.Reflection namespace 's classes can help us
dynamically inspect instance's typeinfo (including class definiation,
members ....). You can try them through Hugh's suggetions.
#Metadata and Reflection in .NET
http://odetocode.com/Articles/288.aspx
Also, as for such dynamic Reflection, undoubtly they'll bring significant
performance overhead. So generally we'd recommend that you avoid using them
if possible.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Derek Harmon" <lo*******@msn.com>
| References: <uH**************@TK2MSFTNGP15.phx.gbl>
| Subject: Re: Code Access to Web Page Control properties
| Date: Thu, 22 Sep 2005 20:19:35 -0400
| Lines: 24
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Response
| Message-ID: <uG**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: mailgw.infragistics.com 216.113.236.146
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.languages.vb:107062
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| "Hugh O" <Hu****@newsgroup.nospam> wrote in message
news:uH**************@TK2MSFTNGP15.phx.gbl...
| > Is there a similar way of getting code access to the properties
associated with that control?
|
| Sounds like what you're looking for is in the System.Reflection
| namespace.
|
| Essentially, you would:
|
| 1. Add Imports System.Reflection.
| 2. Get the Type of Me.Controls(1).Controls(56).
| 3. Enumerate it's properties (using the GetProperties( ) method) on
| Me.Controls(1).Controls(56).GetType. This gives you a
| collection of what are called PropertyInfo objects.
| 4. Pass Me.Controls( 1).Controls( 56) and some Value you
| wish to assign to the PropertyInfo's SetValue( ) method.
|
| Each PropertyInfo you get in step 3 will have a Name property, so
| you can figure out if you're about to call SetValue( ) on the control's
| Visible property or it's EnableViewstate property, for instance.
|
|
| Derek Harmon
|
|
|