Solved

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

Posted on 2011-09-06
3
237 Views
Last Modified: 2012-05-12
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
Comment
Question by:dyarosh
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
ivan_vagunin earned 500 total points
Comment Utility
Hi!
Try imgTempp.Attributes("onclick") = "onImageClick()";
0
 
LVL 18

Expert Comment

by:ivan_vagunin
Comment Utility
Without ';' ;)
0
 

Author Closing Comment

by:dyarosh
Comment Utility
Thanks.  I'm going to be posting one more problem that I have.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now