在asp.net网页表单中使用Sweet alert删除行


function del() {
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {

swal("Poof! Your imaginary file has been deleted!", {
icon: "success",
});
} else {
swal("Your imaginary file is safe!");
}
});
}

我的链接按钮代码是请帮助我如何在中继器中使用链接按钮时使用甜蜜警报

<asp:LinkButton ID="delete_lbtn" runat="server" class="btn btn-danger btn-sm" 
CausesValidation="false" OnClick="delete_lbtn_Click" OnClientClick="del(); return false;"> 
<i class="nav-icon i-Close-Window"> Delete</i></asp:LinkButton>

只需删除您的"return false";在客户端点击事件中。如果返回false,服务器端代码将不会运行,但如果返回try,则会运行。因此:

function del() {
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {

swal("Poof! Your imaginary file has been deleted!", {
icon: "success",
});
return true;
} else {
swal("Your imaginary file is safe!");
return false;
}
});
}

最新更新