473,408 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Loop through controls???

Jay
If I have 10 imagebuttons on a form (imagebutton1, imagebutton2,
imagebutton3, etc.) in asp.net and I want to loop through each one and set
their imageurl in a loop how can this be done.

Something like :

dim i as int16
for i = 1 to 10
imagebutton(i).imageurl="whatever.jpg"
next

The code above does not work... is it possible to do this?

Thanks.
Nov 17 '05 #1
4 1452
dim ctl as Control
for each ctl in me.controls
if typeof ctl is imageButton
ctype(ctl, imageButton).imageurl = "whatever.jpg"
end if
next

"Jay" <msnews.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP12.phx.gbl...
If I have 10 imagebuttons on a form (imagebutton1, imagebutton2,
imagebutton3, etc.) in asp.net and I want to loop through each one and set
their imageurl in a loop how can this be done.

Something like :

dim i as int16
for i = 1 to 10
imagebutton(i).imageurl="whatever.jpg"
next

The code above does not work... is it possible to do this?

Thanks.

Nov 17 '05 #2
check out this article for looping through controls,
http://www.extremeexperts.com/Net/Ar...hControls.aspx

--
Saravana
Microsoft India Community Star,MC**
www.extremeexperts.com

"Jay" <msnews.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP12.phx.gbl...
If I have 10 imagebuttons on a form (imagebutton1, imagebutton2,
imagebutton3, etc.) in asp.net and I want to loop through each one and set
their imageurl in a loop how can this be done.

Something like :

dim i as int16
for i = 1 to 10
imagebutton(i).imageurl="whatever.jpg"
next

The code above does not work... is it possible to do this?

Thanks.

Nov 17 '05 #3
Jay
Thanks a lot. But what if I only wanted to set the imageurl for
imagebutton1, 2, 3 - 10? If there were other imagebuttons on the page they
would be set as well.
"Srinivas Kotipalli" <sr*******@sbcglobal.net> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
dim ctl as Control
for each ctl in me.controls
if typeof ctl is imageButton
ctype(ctl, imageButton).imageurl = "whatever.jpg"
end if
next

"Jay" <msnews.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP12.phx.gbl...
If I have 10 imagebuttons on a form (imagebutton1, imagebutton2,
imagebutton3, etc.) in asp.net and I want to loop through each one and set their imageurl in a loop how can this be done.

Something like :

dim i as int16
for i = 1 to 10
imagebutton(i).imageurl="whatever.jpg"
next

The code above does not work... is it possible to do this?

Thanks.


Nov 17 '05 #4
use a consistent naming convention for the image controls (e.g. image1,
image2 etc)
then something like
dim x as int16
dim ctrlname as string
dim img as Control
for x=1 to 10 ' or whatever
ctrlname="image" & x
img=FindControl(ctrlname) ' find name control
img.imageurl="someimage.jpg"
next

Hope that helps

Roger

"Jay" <msnews.microsoft.com> wrote in message
news:#4**************@TK2MSFTNGP10.phx.gbl...
Thanks a lot. But what if I only wanted to set the imageurl for
imagebutton1, 2, 3 - 10? If there were other imagebuttons on the page they would be set as well.
"Srinivas Kotipalli" <sr*******@sbcglobal.net> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
dim ctl as Control
for each ctl in me.controls
if typeof ctl is imageButton
ctype(ctl, imageButton).imageurl = "whatever.jpg"
end if
next

"Jay" <msnews.microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP12.phx.gbl...
If I have 10 imagebuttons on a form (imagebutton1, imagebutton2,
imagebutton3, etc.) in asp.net and I want to loop through each one and set their imageurl in a loop how can this be done.

Something like :

dim i as int16
for i = 1 to 10
imagebutton(i).imageurl="whatever.jpg"
next

The code above does not work... is it possible to do this?

Thanks.



Nov 17 '05 #5

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

Similar topics

4
by: Ryan Liu | last post by:
How to loop though controls on the form? I set each control's TabStop and TabIndex, but at run time, I press Tab key, it jump though first control to last control and does not go back to the...
4
by: David A. Beck | last post by:
Is there a way I can loop through a form object in ASP.NET codebehind like in VB.NET and get all of the controls?
4
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to...
4
by: sck10 | last post by:
I changed my aspx page to use a master page. The problem is that I can no longer loop through the controls on the content page. My question is how do you loop through the controls on the master...
33
by: Brian | last post by:
I have a list of plain HTML radio buttons that I want to be able to loop through, get the values from them and insert them into a db. each one should be a separate record... Can anyone please give...
3
by: Kezza | last post by:
Hi There.. I have dynamically created some textbox and checkbox controls by adding them to a panel. Now I would like to get the values out. I have created a for each loop that I can see the...
8
by: dominique | last post by:
Hi, Is it possible (in vb.net with WinForms) to loop throw controls inside a container (form or panel) sorting the controls on a property (.tabindex for example) ? My problem : on several...
7
by: J L | last post by:
I need to loop through a form's controls collection and delete some based on type and location. I have tried For..Each and For i = 0 to form.controls.count - 1 but when I delete any it messes up...
10
by: Derek Hart | last post by:
I am going in circles trying to loop through properties on 3rd party controls. For example, I have a textbox that has its maximum length located at MyTextBox.Properties.MaxLength - instead of the...
9
tlhintoq
by: tlhintoq | last post by:
Situation: A Windows Form with a single User Control containing 4 custom controls. This lets me drop the User Control on its own form to make it a dialog, or make it part of a larger configuration...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.