?
Solved

Set object properties with loop

Posted on 2008-06-20
3
Medium Priority
?
174 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 1800 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 200 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

URL rewriting in AWS CloudFront

A quick how-to guide to implement with a Lambda function!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 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