'Sweatalert delete confirmation return value true/false with button in asp.net c#

the sweatalert script is not work when i clicked on the button. How can i solved this problem? when i click the button alert is dislpay then very fast hide and the record will be deleted

JS Script--

function deletealert(pubid)
{
    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!",
        cancelButtonText: "No, cancel plx!",
        closeOnConfirm: false,
        closeOnCancel: false                   
    },
    function (isConfirm) {
        if (isConfirm) {
            swal("Deleted!", "Your imaginary file has been deleted.", "success");
        } else {
            swal("Cancelled", "Your imaginary file is safe :)", "error");
        }
    });
}

ASP.NET--

    <asp:Button ID="delete" runat="server" Text="Delete" class="btn btn-danger" 
    OnClick="delete_Click" />

cs CodeBehind--

    protected void delete_Click(object sender, EventArgs e) {
    delete.Attributes.Add("OnClick", "javascript:return confirmation('" + ID + "')");

    ID = (string)Session["ID"];
    conn.Open();
    SqlCommand cmd = new SqlCommand("Delete from AvailableDevice where ID = '" + Convert.ToInt32(ID) + "'", conn);
    int result = cmd.ExecuteNonQuery();
    conn.Close();
    if (result == 1)
    {
        Response.Redirect(Request.RawUrl);
        Session["ID"] = null;
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source