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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top