473,327 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Code Access to Web Page Control properties

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
4 1708
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Brian W | last post by:
Hi All, I have a web user control that, among other things, provides Print this page, and Email this page functionality I have this script that is to execute on the click of the asp:hyperlinks ...
6
by: Earl Teigrob | last post by:
I am writing an application that dynamically loads user controls at run time based on user options. I would like to give my users the ability to build their own user controls and add them to my...
6
by: William Parker | last post by:
I have a web control I made called header.ascx. It has its own properties and methods I defined. But I cannot figure out how to access this control from my code behind page. I can create the...
2
by: Jon Hyland | last post by:
This might be a dumb question, but what is the best way for one instance of a user control to access properties of an instance of another user control? For example, let's say I have an instance...
10
by: Daves | last post by:
Is there any way to have a custom server control for all aspx pages which runs code before the page_load event? I need some code to be run before the page_load since it's supposed to change some...
3
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
4
by: ArrK | last post by:
I want to use a control frame to create and/or modify the content (images and text) of a display frame - all files and images are client side. . When I try to write to the display frame from the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.