Something like:
Public Function GetAllControlsOfType(ByVal type As Type, ByVal parent As
Control) As ArrayList
Dim arr As New ArrayList()
For Each c As Control In parent.Controls
If (c.HasControls) Then
arr.AddRange(GetAllControlsOfType(type, c))
End If
If (c.GetType().IsAssignableFrom(type)) Then
arr.Add(c)
End If
Next
Return arr
End Function
should work..
You can call it via:
GetAllControlsOfType(new TextBox().GetType(), Page)
If you don't like the "new TextBox().GetType()", you cna get the type via:
Type.GetType("System.Web.UI.WebControls.TextBox, System.Web", true, true)
but you'll need to specify the full assembly name (token, culture,
version..) since System.Web sits in the GAC..
Karl
--
http://www.openmymind.net/ http://www.fuelindustries.com/
"Muckeypuck" <Bl**********@blah.blahwrote in message
news:E3JCg.51$xk3.13@dukeread07...
hello, i would like to write a function that takes a webcontrol type as a
parameter and returns an array of controls based on the type
some thing like:
GetAllControls(typeof(system.web.ui.webcontrols.te xtbox)) 'returns
textboxes
GetAllControls(typeof(system.web.ui.webcontrols.dr opdownlist)) 'returns
dropdowns
GetAllControls(typeof(system.web.ui.webcontrols)) 'returns everything
however i can not find the proper way to write the signature
Public sub GetAllControls(Byref tType as ??????????)
thanks