Search:
Namespaces
Discussions
.NET v1.1
Feedback
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...
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com