确认回传OnClientClick button ASP.NET

Dan Shortmakambi提出了一个问题:Confirm postback OnClientClick button ASP.NET,或许与您遇到的问题类似。

回答者Hans Kesting给出了该问题的处理方式:

Try this:

<asp:Button runat="server" ID="btnUserDelete" Text="Delete" CssClass="GreenLightButton"
                       OnClick="BtnUserDelete_Click"
                       OnClientClick="if ( ! UserDeleteConfirmation()) return false;" 
 meta:resourcekey="BtnUserDeleteResource1" />

This way the "return" is only executed when the user clicks "cancel" and not when he clicks "ok".

By the way, you can shorten the UserDeleteConfirmation function to:

function UserDeleteConfirmation() {
    return confirm("Are you sure you want to delete this user?");
}

希望本文对你有帮助,欢迎支持JavaScript中文网

原文链接:stackoverflow.com

上一篇:custom-guider
下一篇:禁用Android上长水龙头上的上下文菜单

公众号

欢迎 JavaScript 爱好者