How to step through the controls in a webform controls collection

  • Thread starter Thread starter Dave Adler
  • Start date Start date
D

Dave Adler

Can anyone give me an example in vb.net of how to step through all of the
controls in the current webform controls collection to test the Name value
of each control to look for controls that start with a specific name value
using a "for each/next" construct?

Thanks in advance

David
 
Dim objControl As System.Windows.Forms.Control

For Each objControl In Me.Controls
If objControl.Name.StartsWith("Button") Then
MessageBox.Show(objControl.Name)
End If
Next
 
Back
Top