473,473 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
Nov 17 '05 #1
1 1196
You might find the FindControl method to be a convenient way to get a
reference to it.
For example:
Dim MyTextBox = CType(FindControl("TextBox1"), TextBox)

Here's more info:
http://msdn.microsoft.com/library/de...ntroltopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Jeff S" <Je***@asdf.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Randi | last post by:
Hi all, I have this project to use the ADODB control to acces and manipulate the Access DB. I amd the mistake of first doing this project with just the data control. It worked fine with this...
4
by: (Pete Cresswell) | last post by:
I'm getting nodes into the thing, but when the dust settles, only the root-level nodes are visible. I know they're there because .Nodes.Count gives the right number.\ But I don't really...
2
by: RBohannon | last post by:
I found this in the Help file: ' Refer to a control by its index in the controls ' collection. Me(0) Can I view a list of controls on a form and see their index numbers? Or how do I find the...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
7
by: tom | last post by:
Hi, I want a listbox below a hidden calendar control. The problem is that the listbox will shadow the calendar when the calendar is visible. How can I bring the calendar from back to front? ...
1
by: I am Sam | last post by:
using System; using System.Drawing; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.ComponentModel;...
2
by: GY2 | last post by:
How do I refer to controls by a string variable name instead of by integer item index? A form contains 7 rich textbox controls labeled rtb1-rtb7. In VB6 I could use the following code to loop...
2
by: Gidi | last post by:
Hello, I've a strange problem with substring function. I'm geting a string from my SQL DataBase and i want to split it to two substings. here is what i do: if(temp.Length>80 &&...
11
by: Web Search Store | last post by:
Hello, I set up a web page with 2 user controls. In classic asp, the first one did all the declarations, and the second one used the values, and could reset it. In ASP.Net so far I can't...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.