.NETGURU
Reflection conundrum.
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-reflection' list.


David Brophy

Hi,

In my infinite search to reduce the number of lines of code I write, I =
have a
problem. Consider the following situation, where I have 5 panels, names =
panelX,
with X=3D1 to 5.=20
I want to change the Visible property of each of them to true, using a =
loop.

I've invented a mythical GetObject(string objectName) function, which =
returns
a reference to the object specified by the string.

Initially, it smacks of things you can't do in compiled languages, but =
the
Reflection classes have a lot of similar functionality.=20

I'm thinking my GetObject function would be some convolution of the
Type.InvokeMember() function, but I can't figure out how to do it.

Any help would be gratefully received.

My Code:

[Original message clipped]

- David Brophy
Director, Cambro Limited,
(023) 80 679550=20
Click here to reveal e-mail address

Reply to this message...
 
    
Andy Eunson
In a web application you can use the Page.FindControl method to return a
refernece to a control by name

Dim MyControl as System.Web.Ui.Control
MyControl = Page.FindControl("Panel1")

You could probably do something like:

Dim x as integer
Dim MyControl as System.Web.Ui.Control
For x = 1 to 5
MyControl = Page.FindControl( New String( "Panel" & x ) )
MyControl.Visible = False
Next

Andy

----- Original Message -----
From: "David Brophy" <Click here to reveal e-mail address>
To: "ngfx-reflection" <Click here to reveal e-mail address>
Sent: Thursday, November 01, 2001 11:17 AM
Subject: [ngfx-reflection] Reflection conundrum.

Hi,

In my infinite search to reduce the number of lines of code I write, I have
a
problem. Consider the following situation, where I have 5 panels, names
panelX,
with X=1 to 5.
I want to change the Visible property of each of them to true, using a loop.

I've invented a mythical GetObject(string objectName) function, which
returns
a reference to the object specified by the string.

Initially, it smacks of things you can't do in compiled languages, but the
Reflection classes have a lot of similar functionality.

I'm thinking my GetObject function would be some convolution of the
Type.InvokeMember() function, but I can't figure out how to do it.

Any help would be gratefully received.

My Code:

[Original message clipped]

- David Brophy
Director, Cambro Limited,
(023) 80 679550
Click here to reveal e-mail address

| [ngfx-reflection] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngbeta.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
 
System.Type
System.Web.UI.Page




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification