Try returning
false
when user does not confirm.
<asp:Button ID="Button1"
runat="server"
PostBackUrl="~/Transferencia.aspx"
Text="aceptar"
OnClick="Button1_Click"
OnClientClick="if ( ! UserConfirmation()) return false;" />
Use the following
JavaScript
.
function UserConfirmation() {
return confirm("Do you want to cancel ?");
}
So, when user presses
cancel
, the function will return
false
to
OnClienClickEvent
and satisfies the if condition.
So, again it executes
return false;
inside the Event. So,
PostBack
does not happen.