Solved

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

Posted on 2011-09-06
3
249 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hidden Field Value 10 61
Auto refresh part of an MVC5 View 7 61
Error on Add method 1 38
IIS issues - Convert to Application - APS.NET v4.0 3 23
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

16 Experts available now in Live!

Get 1:1 Help Now