当你在服务器控件(Buttton等可提交表单的控件)执行客户端javascript事件时,此时你想让他没有通过一定条件的时候不回传表单,现在你要做的就是,在控件的客户端事件返回false,在事件调用处使用return,这样就不会提交了
例如:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
// <!CDATA[
function doClick()
{
alert("you have do client click");
return false;
}
// ]]>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnSubmit" runat="server" OnClientClick="return doClick()" OnClick ="HandleSubmit" Text="Submit" />
</div>
</form>
</body>
</html>