I have a link button inside a repeater like this:
<asp:LinkButton ID="lnkDelete" runat="server" CommandName="delete" OnClientClick='javascript:return showConfirm("Are you sure you want to delete?")'
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ReasonId") %>'>Delete</asp:LinkButton>
and I use jQuery noty plugin to show confirmation when user click on delete.
The showConfirm()
function is like this:
function showConfirm(message) {
var n = noty({
text: message, //'Are you sure?',
type: 'confirm',
dismissQueue: false,
layout: 'center',
theme: 'defaultTheme'
, buttons:
[{
addClass: 'btn btn-primary', text: 'Ok', onClick: function ($noty) {
$noty.close(); return true;
}
},
{
addClass: 'btn btn-danger', text: 'Cancel', onClick: function ($noty) {
$noty.close(); return false
}
}]
})
}
But it won' t return true
or false
. How can I return true
or false
when clicking on ok
or cancel
button.?
You can not return
true
orfalse
the way you wish, because actually this is not a "real modal dialog" thats makes the browser, or any other window to wait for return.The only browser dialog that can do that, using javascript is the
confirm
dialog.The
dialog
you use is actually one div thats open on your page and show a message, unable to hold the post back from your input control. Alternative you may design it as to open, and in the case of Yes, to redirect to the page you wish, but the link that is calling it must only open it.