Refer to Control by ID or Other String (not Index)

  • Thread starter Thread starter Jeff S
  • Start date Start date
J

Jeff S

Using VB.NET/code behind, I'd like to programmatically access 15 imagebutton
controls by their ID (or some other identifying string). The ID of each of
the imageButton controls is Thumb0, Thumb1...Thumb14. I'd like to set
properties for each one from the code behind module, however, the
Page.Controls collection enables access only by index value. Is there a way
to access the control via its ID in a loop?... something like the following
p-code demonstrated (I know it doesn't work - but I'd like this
functionality):

Dim X as Integer
For X = 0 to 14
ImageControlName & CStr(X).ImageURL = strTemp
Next X

I don't want to loop through the entire controls collection and check TypeOf
Control to accomplish this.

Thanks in advance.

Jeff
 

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