We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


to get collection of ImageButton controls in code behind page

Econify asked
Medium Priority
Last Modified: 2011-10-03
I need to apply rollover effect to buttons on my aspx page. I am using javascript function for that in which I use onMouseUp and onMouseDown events for the rollover effect. I have lots of controls and so I want collection of the ImageButton controls in code behind page to apply onMouseUp and onMouseDown events for them. Plz let me know how to get the collection of controls in code behind page and how to apply events for this collection.
Watch Question

Most Valuable Expert 2012
Top Expert 2008
VB.NET example:

    Dim form As HtmlControls.HtmlForm = Me.FindControl("form1")
    For Each ctl As Control In form.Controls
      If TypeOf ctl Is ImageButton Then
      End If


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Bob's solution above will get the collection, to apply the javascript events:

If TypeOf ctl Is ImageButton Then
       ctl.Attributes.Add("OnMouseOver", "this.className='ibover';")
       ctl.Attributes.Add("OnMouseOut", "this.className='ibnormal';")
End IF

Substitute ibover and ibnormal for your CSS Classes.
Forced accept.

EE Admin
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.