i have linkbutton
in my aspx
page as
<asp:LinkButton ID="LinkButton1" OnClientClick="if ( !MutExChkList()) return false;" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
where on clientclick
event i need to confirm something from user by using javascript
and if javascript returns true then i need to fire OnClick
event of button and if javascript
returns false then i need to do nothing say don't postback
the page...
Below is my javascript
<script type="text/javascript">
function MutExChkList() {
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) {
return true;
} else {
return false;
}
});
};
</script>
i got help from following links
Stopping onclick from firing when onclientclick is false?
Prevent LinkButton post back OnClientClick not working. Why?
and much more searching....
if i use OnClientClick="MutExChkList(event);"
then it postback in both cases either true
or false
if i use OnClientClick="if ( !MutExChkList()) return false;"
then it does not postback
when function returns true
Can any one help me to get out of this... thanks in advance... i am using asp.net