返回false不会取消asp.net回发

Reg*_*ser 1 asp.net

我很困惑为什么这个返回false不会取消后退.

 function validate() {
         return false;
        }



 <asp:Button ID="Button1" type="submit" OnClientClick="validate();" runat="server" Text="send"  />
Run Code Online (Sandbox Code Playgroud)

最疯狂的部分是下面的代码取消了回发,但我需要在上面的函数中发生这种情况:

 <asp:Button ID="Button1" type="submit" OnClientClick="return false;" runat="server" Text="send" style="margin-right:150px;" />
Run Code Online (Sandbox Code Playgroud)

The*_*son 5

尝试从函数中返回值,就像这样

<asp:Button ID="Button1" type="submit" OnClientClick="return validate();" runat="server" Text="send"  />
Run Code Online (Sandbox Code Playgroud)

否则你只是执行一个返回布尔值的javascript函数.