取消绑定 asp 按钮的客户端点击事件,但保留附加 asp 按钮的服务器点击事件

Unbind the client click event of a asp button but keep the server click event of the asp button attached

我需要针对某些特定条件在客户端点击事件中触发服务器点击事件。我知道,如果客户端点击 returns true 然后服务器点击事件被触发。 OnClientClick 我正在显示一个 jConfirm。我想在 jConfirm returns true 时触发服务器单击同一按钮。我正在尝试这个:

<asp:Button ID="Button1" runat="server" Text="ADD" OnClick="btnAdd_Click" ValidationGroup="Add" CausesValidation="true" OnClientClick="return Validate()" />


function Validate() {
     if (Page_ClientValidate('Add')) {
         if ($('#<%=ddlTestField.ClientID%>').val() == '0') {
             var strMessage = 'Continue?';
             $.alerts.okButton = 'OK';
             $.alerts.cancelButton = 'CANCEL';
             jConfirm(strMessage, 'CONFIRM MESSAGE', function (r) {
                if(r)
                {
                    $('#<%=Button1.ClientID%>').unbind("click"); // To unbind the client event
                    $('#<%=Button1.ClientID%>').click(); // To fire the server click event, But it is firing the client click also. A loop goes on
                }
            });
        }
        return true;
    }
    return false;
}

我找到了解决方案

if(r)
{
      <%= Page.ClientScript.GetPostBackEventReference(Button1, String.Empty) %>;
}