By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,928 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,928 IT Pros & Developers. It's quick & easy.

Code Access to Web Page Control properties

P: n/a
Hi,
I have been able to use the following kinds of code to access basic
information on the individual controls that would be in any Web page.

?Me.Controls(1).Controls(56).GetType.Name ' control type
?Me.Controls(1).Controls(56).ID ' control name

Is there a similar way of getting code access to the properties associated
with that control? I am talking about the properties that would appear in
the Property window within the Visual Basic.Net Designer phase.

Thanks,
hugh
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"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
Nov 21 '05 #2

P: n/a
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
|
|
|

Nov 21 '05 #3

P: n/a
Thanks Derek and Steven,
It was just a proposed tool to use in development, merely for generating
summary control documentation I was not planning on using it for setting
properties in runtime.
thanks,
hugh
"Derek Harmon" <lo*******@msn.com> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
"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

Nov 21 '05 #4

P: n/a
Thanks for your followup Huge,

If just for development usage, then feel free to use it :-)

Regards,

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: "Hugh O" <Hu****@newsgroup.nospam>
| References: <uH**************@TK2MSFTNGP15.phx.gbl>
<uG**************@TK2MSFTNGP12.phx.gbl>
| Subject: Re: Code Access to Web Page Control properties
| Date: Fri, 23 Sep 2005 09:49:46 -0400
| Lines: 37
| 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: <#M**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: pcp01784214pcs.audubn01.nj.comcast.net 68.46.176.167
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSF TNGP08.phx.gbl!tk2msftngp1
3.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.languages.vb:107158
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Thanks Derek and Steven,
| It was just a proposed tool to use in development, merely for generating
| summary control documentation I was not planning on using it for setting
| properties in runtime.
|
|
| thanks,
| hugh
| "Derek Harmon" <lo*******@msn.com> wrote in message
| news:uG**************@TK2MSFTNGP12.phx.gbl...
| > "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
| >
|
|
|

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.