Solved

Set object properties with loop

Posted on 2008-06-20
3
169 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

735 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