Solved

Set object properties with loop

Posted on 2008-06-20
3
165 Views
Last Modified: 2013-11-26
I have a page containing 24 ImageButtons.  Is there a way to loop through all 24 objects and set the following properties?

ImageUrl
Visible

I have tried the following code but it only exposes the Visible property.

      For Each MyImage As Control In Me.Controls(3).Controls
         If TypeOf (MyImage) Is ImageButton Then
            MyImage.Visible = False
         End If
      Next

Thanks
0
Comment
Question by:Ray Turner
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 450 total points
ID: 21833974
you need a cast:

     Dim img as ImageButton
     For Each MyImage As Control In Me.Controls(3).Controls
         If TypeOf (MyImage) Is ImageButton Then
            img = DirectCast(MyImage, ImageButton)
            img.Visible = False
            img.ImageUrl = whatever
         End If
     Next
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 50 total points
ID: 21834039
* minor thing...the parenthesis around MyImage are not needed...

    If TypeOf MyImage Is ImageButton Then
0
 

Author Closing Comment

by:Ray Turner
ID: 31469289
Thanks!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now