Solved

Set object properties with loop

Posted on 2008-06-20
3
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 86

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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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