First through the onclick validation client authentication, and then in the implementation of the service-side method OnServerClick
<input id= "Butsearch" runat= "Class=" C3 F14 Fw "onmouseout=" Javascript:this.classname= ' C3 '; "Onmouseover=" Javascript:this.classname= ' C4 ';
onclick= "return checkdate ();" onserverclick= "Butsearch_onclick" type= "button" value= "Query" >
<script language= "JavaScript" >
function Checkdate () {
var D1 = document.getElementById ("Datecustomerstar"). Value;
var D2 = document.getElementById ("Datecustomerend"). Value;
if (Date.parse (D1.replace ("-", "/")) > Date.parse (D2.replace ("-", "/"))) {
Alert ("Start time is greater than end time, please check!");
return false;
}
__doPostBack (' <%= butsearch.uniqueid%> ', ');
}
</script>
The key point is the need to use __doPostBack (' <%= butsearch.uniqueid%> ');
This will trigger the OnServerClick method.