.NETGURU
Seeing common properties of custom controls in loop through page collection.
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcontrolsvb' list.


Jay Chapman
hey .net gurus-

I have created a few custom web controls that inherit a regular web control
(textbox, checkbox, etc.) and gave them a few extra properties. Now I want
to be able to loop through all the controls on a web page, and if a given
control is any of my custom controls, I want to access a property I have
created in each. How do I accomplish this?

If I do a:

Dim ctl As Control
For Each ctl In page.controls

then I will not get my custom property to be recognized, I just get what is
standard for "control".

If I dimension as one of my custom controls, I cannot pick out the other
types of custom controls even though they have the same properties to look
at.

any help would be appreciated.

thanks,

Jay Chapman
BCA Technologies, Inc.
407.659.0653 x326
Click here to reveal e-mail address
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.303 / Virus Database: 164 - Release Date: 11/24/2001

Reply to this message...
 
    
Susan Warren
Jay --

You just need to walk the control tree recursively, like this:

Sub Page_Load()
WalkControls(Page, 1)
End Sub

Sub WalkControls(ByVal parent As Control, ByVal level As Integer)

Dim spaces As String =3D New String("-"c, level * 4)

Dim ctrl As Control
For Each ctrl In parent.Controls

Response.Write(spaces & "<b> " & ctrl.ID & "</b> " &
ctrl.GetType().FullName & "<br>")

        ' **** Recurse into this item's Controls collection if
it's not empty
If ctrl.Controls.Count > 0 Then
WalkControls(ctrl, level + 1)
End If

Next

End Sub

-----Original Message-----
From: Jay Chapman [mailto:Click here to reveal e-mail address]=20
Sent: Wednesday, November 28, 2001 12:15 PM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] Seeing common properties of custom controls
in loop through page collection.

hey .net gurus-

I have created a few custom web controls that inherit a regular web
control
(textbox, checkbox, etc.) and gave them a few extra properties. Now I
want
to be able to loop through all the controls on a web page, and if a
given
control is any of my custom controls, I want to access a property I have
created in each. How do I accomplish this?

If I do a:

Dim ctl As Control
For Each ctl In page.controls

then I will not get my custom property to be recognized, I just get what
is
standard for "control".

If I dimension as one of my custom controls, I cannot pick out the other
types of custom controls even though they have the same properties to
look
at.

any help would be appreciated.

thanks,

Jay Chapman
BCA Technologies, Inc.
407.659.0653 x326
Click here to reveal e-mail address
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.303 / Virus Database: 164 - Release Date: 11/24/2001

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

Reply to this message...
 
 




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