Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
difference between onsubmit and onclick
Posted

Hi,

onclick and onsumbit both are events. we all know about this.

In basic onsumbit invokes when user clicks on input element type "submit"

same as onclick invokes when user clicks an element which can holds onclick event.

input type sumbit only can post data to server.

But in asp onclick event works as submit event.It has some work in browser.

you can see in source code after page loading in browser.

all placed asp buttons are rendered to input type sumbit.

In server side sumbit request checks which control raises postback in eventargument

or request.params.allkeys[2]


I hope you understood What I said

All the Best
 
Share this answer
 
Have a look at below Question-Answer thread on the same topic.

http://webdeveloper.com/forum/showthread.php?t=182709
 
Share this answer
 
Basic difference:

onclick: Script/function/method to be run on a mouse click.

onsubmit: Script/function/method to be run when a form is submitted.

hope it helps :)
 
Share this answer
 
v2
OnSubmit works when Form data is Submitted.
OnClick works when a control is clicked.
On Submit also works with Enter Key.
 
Share this answer
 
onsubmit is triggered whenever the form is about to be submitted.
onclick is triggered when the specific button is clicked.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900