Difference between OnClick and OnClientClick Javascript event

Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 1329
OnClick and OnClientClick both uses the Javascript functions. Or these are like an event which use javascript function.

OnClick -> Used for both Asp.Net button i.e. command button, link button and HTML button.
OnClientClick -> Used for only Asp.Net button.

For Example :-

<script type = "text/javascript" language="javascript">
function get_alert()

To understand this,

<asp:button id="btn_show_message1" runat="server" OnClientClick = "get_alert(); return false;" Text = "Show message using OnClientClick"/>

<input type="button" id="btn_show_message2" name="button" value ="Show message using OnClick" onclick = "get_alert();"/>

Comments or Responses

Login to post response