gpt4 book ai didi

javascript - 在 SweetAlert 中传递 ASP.NET 按钮单击事件

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:28:33 26 4
gpt4 key购买 nike

我有一个执行挂起操作的 C# 方法。

 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 做同样的事情吗?

最佳答案

你可以尝试这样的事情,如果这不是你想要的,请告诉我

$('#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(); }
});
});

关于javascript - 在 SweetAlert 中传递 ASP.NET 按钮单击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36929929/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com