Improve company productivity with a Business Account.Sign Up

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

How do I add an onclick client side handler to my ASP:Image

I am dynamically adding images to a Panel on my ASP.NET page using the following code in my Page Load event:

        For Each img In nodeList
            Dim imgTemp As New Image
            imgTemp.ID = "CurImage" & cnt.ToString
            imgTemp.CssClass = "borders_off"
            imgTemp.ImageUrl = img.InnerText
            CurrentPanel.Controls.Add(imgTemp)
            cnt = cnt + 1
        Next

What I want to be able to do is to change the CssClass to "borders_on" when the image is clicked if CssClass is "borders_off" and to "borders_off" if the CssClass is "borders_on".  I know I can do it on the server side but I don't want to have to go back to the server and would like to do it on the client side.  The ASP:Image doesn't have a property for a client side onclick that I can find.  Is there a way to do what I want?
0
dyarosh
Asked:
dyarosh
  • 2
1 Solution
 
ivan_vaguninCommented:
Hi!
Try imgTempp.Attributes("onclick") = "onImageClick()";
0
 
ivan_vaguninCommented:
Without ';' ;)
0
 
dyaroshAuthor Commented:
Thanks.  I'm going to be posting one more problem that I have.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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