Solved

What is the difference between onclick and onclientclick in javascript?

Posted on 2013-06-30
4
732 Views
Last Modified: 2013-07-02
What is the difference between onclick and onclientclick in javascript?

Both seem to be executing the functions on the client side.

<img id="myimage" onclick="changeImage()" onclientclick = "ChangeTitle()"
src="pic_bulboff.gif" width="100" height="180">

Please advise.

Thanks
0
Comment
Question by:Ricky66
4 Comments
 
LVL 12

Assisted Solution

by:duttcom
duttcom earned 150 total points
ID: 39288927
As outlined on this page - http://forums.asp.net/t/1249580.aspx

OnClick will work on server side , OnClientClick will execute on client side before control passed to server.
 
If the client side code returns TRUE then it will go to server.
 
Generally programmers use onclientclick to validate the controls like textbox,etc.
0
 
LVL 21

Assisted Solution

by:Dale Burrell
Dale Burrell earned 100 total points
ID: 39288928
AFAIK there is no onclientclick in javascript, it only exists in asp.net, where it gets rendered as onclick to the client i.e. in javascript?

What made you think it was a javascript event?
0
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 250 total points
ID: 39288931
This event(Onclientclick ) does not exist for pure html img
http://www.w3schools.com/tags/ref_eventattributes.asp
http://www.w3schools.com/tags/tag_img.asp
The Onclientclick  is simply ignored as it is an invalid attribute. For all practical purposes you only need onclick to implement your JS click event.

Note: Onclientclick only exists for asp.net controls like buttons to allow you execute JS scripts /methods before running the event server code.
0
 

Author Closing Comment

by:Ricky66
ID: 39293829
Thanks!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

825 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