Solved

Set object properties with loop

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

785 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