Solved

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

Posted on 2011-09-06
3
275 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
ID: 36488486
Hi!
Try imgTempp.Attributes("onclick") = "onImageClick()";
0
 
LVL 18

Expert Comment

by:ivan_vagunin
ID: 36488498
Without ';' ;)
0
 

Author Closing Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 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