Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim controlList As New List(Of Control)
controlList = AddControls(Page.Controls, controlList)
For Each ctl As Control In controlList
Response.Write(ctl.ID & "<br/>")
'Here I setup property Enabled of control textbox1
CType(Me.FindControl("textbox1"), TextBox).Enabled = True
'I'd like to setup property Enabled of control ctl.ID, but how to invoke <type of ctl>
CType(Me.FindControl(ctl.ID), <type of ctl> ).Enabled = True
Next
End Sub
Private Function AddControls(ByVal page As ControlCollection, ByVal controlList As List(Of Control)) As List(Of Control)
For Each c As Control In page
If c.ID IsNot Nothing Then
controlList.Add(c)
End If
If c.HasControls() Then
AddControls(c.Controls, controlList)
End If
Next
Return controlList
End Function
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.