OnClick is a server-side event for a button
OnClientClick is a client-side event for button
Generally we use OnClientClick to verify our submission data, but this must return ture or false, that is, must add return, otherwise the onclick fails. When False is returned, the onclick server-side event is aborted, and when your JS verification has an error, it also skips the validation and executes the server-side event OnClientClick directly.
Example: Click the button to determine whether the text box is empty
In an. aspx file, you can write as follows:
<asp:textbox id= "Pwdtext" runat= "Server" textmode= "Password" > </asp:TextBox>
<asp:imagebutton id= "OKButton" runat= "Server" onclientclick= "return Checkinput ();" text= "OK"/>
<script type= "Text/javascript" language= "JavaScript" >
function Checkinput ()
{
if (document.getElementById ("<%=pwdtext.clientid%>"). Value = = "")//With Master method
{
Alert ("Please fill in the password!") ");
return false;
}
return true;
}
</script>
If you do not have a master or if the document.getElementById ("Pwdtext"). value.length==0) is empty,
OnClientClick is a client-side event for button