Hi eshwar,
If you want to perform some task on server side on the confirm button click of Sweet Alert 2 then you need to make ajax call and acheive the task you cant directly call the server side code.so you need to use call back function in which ajax request needs to be made.
For more detail on SweetAlert2 refer below link.
https://github.com/limonte/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2
I have created a sample which full fill your requirement you need to modify it according to your need.
HTML
<div>
<div>
<asp:ScriptManager ID="ScriptManager" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<asp:Button ID="btnSweetAlert" runat="server" Text="Delete" OnClientClick="return functionConfirm(this);" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.5/bluebird.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script type="text/javascript" src='https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.min.js'> </script>
<link rel="stylesheet" href='https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.min.css'
media="screen" />
<link rel="stylesheet" href='https://cdn.jsdelivr.net/sweetalert2/6.3.8/sweetalert2.css'
media="screen" />
<script type="text/javascript">
function functionConfirm(event) {
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, cancel!',
confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger',
buttonsStyling: false
}).then(function (result) {
if (result) {
$.ajax({
type: "POST",
url: "Default4.aspx/DeleteClick",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
swal("Data Transfered SuccessFully", r.d, "success");
}
});
}
},
function (dismiss) {
if (dismiss == 'cancel') {
swal(
'Cancelled',
'Your imaginary file is safe :)',
'error')
}
});
}
</script>
</div>
</div>
C#
[System.Web.Services.WebMethod]
public static string DeleteClick()
{
//Do your Stuff Here.
return "ButtonClicked";
}
VB.Net
<System.Web.Services.WebMethod> _
Public Shared Function DeleteClick() As String
'Do your Stuff Here.
Return "ButtonClicked"
End Function
ScreenShot
