Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

to get collection of ImageButton controls in code behind page

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.
0
Econify
Asked:
Econify
2 Solutions
 
Bob LearnedCommented:
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
    Next

Bob
0
 
traxionCommented:
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.
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now