简体   繁体   中英

Double confirmation for deleting ITEM from DB?

I want to delete a huge records for a button click from DB .hard delete .My requirement is to prompt user twice before deleting . 1.Are you want to delete ?? by confirm box wheich i have already done 2.From cs page in button click like "are you sure to delete 500 items"

<asp:Button ID="btnReviewAll" Visible="false" runat="server" Text="Review All" 
                        CssClass="button" ToolTip="Click to Review All" OnClick="btnReviewAll_Click" OnClientClick="javascript:return  confirm('Are you sure want to Review all Closed Items??');" />

in button click in .cs page i am getting record count ..how to prompt user for proceed and show in any confirmation box.

protected void btnReviewAll_Click(object sender, EventArgs e)
        {
            try
            {
               List<Items> lstWorkItems = objBPC.GetCurrentWorkItems();
               //what to write here

            }
            catch (System.Exception ex)
            {
                Utils.DisplayMasterError(this.Page.Master, ex);
            }

Try using javascript function

<asp:Button ID="btnReviewAll" 
Visible="false" 
runat="server" 
Text="Review All" 
CssClass="button" 
ToolTip="Click to Review All" 
OnClick="btnReviewAll_Click" 
OnClientClick="javascript:confirmation();" />


<script>
function confirmation() {

    var yes = confirm("Are you sure want to delete that");

    if (yes) {

        var confirmyes = confirm("do you want to confirm delte");

        if (confirmyes) {
            return true;
        }

    }
    return false;

}

</script>

Found this when trying to get double confirmation working. The code posted by Rafee didnt seem to work. W3C stated The confirm() method returns true if the user clicked "OK", and false otherwise.

So here's what I used;

    $('.disableConfirm').on('click', function(){

        if ( confirm('Confirm 1') ) {

            if ( confirm('Confirm 2') ){
                return true;
            }

        }
        return false;

    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM