OnClick,OnClientClick and OnSubmit events [Resolved]

Posted by Rasagna under ASP.NET on 12/29/2015 | Points: 10 | Views : 2335 | Status : [Member] | Replies : 1
Hii,
Can anyone elaborate about OnClick,OnClientClick and OnSubmit events and especially the variations or differences between these events.




Responses

Posted by: Sheonarayan on: 12/29/2015 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
Use of OnClick

For Server control: If this is set in asp:Control, it fires server side method on click of the control, normally it submits the form on the server.

For HTML element: If this is set in HTML element, it fires client side JavaScript function on click of the element, it may or may not submit the form, simply fires a JavaScript function.

Use of OnClientClick

OnClientClick is only used to specify the function name that fires at client on the click of the server control. If asp:Control has both OnClick and OnClientClick specified, first onClientClick is called that calls JavaScript function and then OnClick (server side) method is called.

Use of OnSubmit

It is an event of <form> element that fires when submit button of the form is clicked (input type="submit"), it fires client side JavaScript function.

Hope this helps.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Rasagna, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response