OnClientClick is a client-side script, typically using JavaScript, running on the client, ie, and immediately after clicking.
OnClick is a server-side event handler, using C # or vb.net, on the server side, which is IIS, click the button, execute the postback, and then run.
If you want to call the OnClientClick before you call the OnClick event, you should return false in the OnClientClick event. If you do not return false, the OnClick event will continue to be invoked after the OnClientClick is executed.
The implementation method is as follows:
<asp:button id= "Btn_save" runat= "Server" text= "save" cssclass= "Button_bak" onclientclick= " return Whetherempty (); " onclick= "Btn_save_click"/>
JavaScript implementations are as follows:
<script language= "javascript" type= "Text/javascript" >
Function Whetherempty ()
{
//alert ("KPI information cannot be all empty. ");
emptflag = false ;
var kpiname = document.getElementById ("<%=txt_KPIName.ClientID%>"). Value;
var jobgoal = document.getElementById ("<%=txt_JobGoal.ClientID%>"). Value;
var weight = document.getElementById ("<%=txt_Weight.ClientID%>"). Value;
var standard = document.getElementById ("<%=txt_Standard.ClientID%>"). Value;
if (kpiname = "" && jobgoal = "" && weight = "" && Standard = = "")
{
Emptflag = true;
}
if (Emptflag)
{
Alert ("KPI information cannot be all empty. ");
return false;
}
}
</script>
If onclientclick= " return Whetherempty ()" No return, in JavaScript even return Fales,onclick will still execute.