2016-04-29 68 views
4

我有一个C#方法,它执行挂起操作。传递ASP.NET按钮单击SweetAlert中的事件

protected void SuspendButton_OnClick(object sender, EventArgs e) 
    { 
     var accountNumberId = DepositAccount.DepositAccountNumberId; 
     var depositAccount = AccountHolders.GetAccountHolder(accountNumberId); 

     if (depositAccount == null) 
     { 
      ShowFailModal("No Account Selected"); 
     } 

     Common.Deposit.AccountSuspension accntSuspension = new Common.Deposit.AccountSuspension(); 
     accntSuspension.AuditTS = BusinessLayer.Core.DateConversion.GetCurrentServerDate(); 
     accntSuspension.AuditUserId = UserId; 
     accntSuspension.Description = DescriptionTextBox.Text; 
     accntSuspension.SuspendedDate = GetDate; 
     accntSuspension.AccountNumberId = accountNumberId; 

     if (depositAccount != null) 
     { 
      InsertSuspendedAccount(accntSuspension); 
     } 

    } 

我使用BootBox为同现在

$('#SuspendButton').on('click', function (evt) { 
 
      evt.preventDefault(); 
 
      var message = "Are you sure you want to Suspend this Account?"; 
 

 
      bootbox.confirm(message, function (result) { 
 
       if (result === false) { 
 
        evt.preventDefault(); 
 
       } else { 
 
        // $.showprogress("Account Suspending.Please Wait..."); 
 
        window.__doPostBack("<%= SuspendButton.UniqueID %>", ""); 
 
       } 
 

 
      }); 
 
     });

这是SweetAlert的样本:

swal({ title: "Are you sure?", 
 
     text: "You will not be able to recover this imaginary file!", 
 
     type: "warning", 
 
     showCancelButton: true, 
 
     confirmButtonColor: "#DD6B55", 
 
     confirmButtonText: "Yes, delete it!", 
 
     closeOnConfirm: false 
 
     }, 
 
     function(){ 
 
     swal("Deleted!", "Your imaginary file has been deleted.",  "success"); 
 
});

如何让它像BootBox一样工作?就像在BootBox中,当我按下SuspendButton时,它会抛出一个bootbox.confirm弹出窗口,如果我按下O键,K就会执行底层操作。我可以用SweetAlert ?

回答

1

你可以尝试这样的事情,让我知道这是不是你想要

$('#SuspendButton').on('click', function (evt) { 
      evt.preventDefault(); 
      //var message = "Are you sure you want to Suspend this Account?"; 

     swal({ title: "Are you sure?", 
      text: "You will not be able to recover this imaginary file!", 
      type: "warning", 
      showCancelButton: true, 
      confirmButtonColor: "#DD6B55", 
      confirmButtonText: "Yes, delete it!", 
      closeOnConfirm: false 
      }, 
      function(isConfirm){ 
      if (isConfirm) {  
       // $.showprogress("Account Suspending.Please Wait..."); 
       window.__doPostBack("<%= SuspendButton.UniqueID %>", ""); 
      } else {  
      evt.preventDefault(); } 
     });  
    }); 
+0

谢谢先生。它的工作。这就是我想要的。你为我的生活节省了一些时间。:) – OLDMONK

0

尝试这个东西,所有的 首先把你的甜蜜,报警代码在一些功能让说“暂停()” 例如:

function Suspend() 
    { 
swal({ title: "Are you sure?", 
     text: "You will not be able to recover this imaginary file!", 
     type: "warning", 
     showCancelButton: true, 
     confirmButtonColor: "#DD6B55", 
     confirmButtonText: "Yes, delete it!", 
     closeOnConfirm: false 
     }, 
     function(){ 
     swal("Deleted!", "Your imaginary file has been deleted.",  "success"); 
}); 
} 

现在对在.aspx/.cshtml侧 “的onClick()” 例如分配功能名称