Reputation: 11
I have a image on which I am opening an alert. On confirmation in this alert, I am triggering the server click event. Here is a quick piece of code.
function showConfirmMessage() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this data!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
}, function () {
document.getElementById("btnDeleteUser").click();
});
return false;
}
Here is the code of the button.
<asp:Button runat="server" ID="btnDeleteUser" ClientIDMode="Static" class="hidden" type="submit" OnClick="btnDeleteUser_Click" />
document.getElementById("btnDeleteUser").click();
this line is called successfully when I click confirm in the alert box. But the actual event is never fired. The page is never submitted back to the server.
I am unable to figure out what is missing here. There are no errors in the console. Application never reaches the server side function.
Upvotes: 1
Views: 40
Reputation: 75
you should use it:
document.getElementById("<%= btnDeleteUser.ClientID %>").click();
Upvotes: 1