Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my case when I click on button confirm-box is called but at the same time server side code executes without confirmation. My code is

JavaScript
 <script src="assets/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
function btnApprovePayments() 
{  
    var ans = checkrecordofpayment(); //here returns true or false            
    if (ans == true) {
         bootbox.confirm("Are You Sure To Approve This Payment ?", function (e) {                  
              if(e)
              { return true; }
         });              
    }     
}

ASP
<asp:Button ID="btn_Approve_Payments" runat="server" Text="Approve" OnClientClick="return btnApprovePayments();" onclick="btn_Approve_Payments_Click" />
Posted

try this


JavaScript
function btnApprovePayments()
{
    var ans = checkrecordofpayment(); //here returns true or false
    if (ans == true) {
         bootbox.confirm("Are You Sure To Approve This Payment ?", function (e) {
              if(e)
              { return true; }
         });
    }
return false;
}
 
Share this answer
 
Comments
phil.o 24-Jan-14 8:29am    
if (ans == true)
Why not simply if (ans)?
Karthik_Mahalingam 24-Jan-14 9:00am    
both are same only, i just added the line "return false"
if( boolean) //
rahul003 25-Jan-14 7:17am    
thanks for reply. i try this but cancel button of confirm box not work well and when ok button click server side code does not executes on my side.
SQL
bootbox.confirm is asynchronus in behaviour so we can't stop its flow. we have to change our behaviour of the problem

first of all you have to prevent the default behaviour of bootbox by applying e.preventdefault(); then add your logic in true section whatever you want to do . then call server side function by using __doPostBack('btnDelete', 'OnClick');


$(function () {
    $(".popup_button_delete").click(function (e) {
        e.preventDefault();
        var counter = GetSelected();
        if (counter > 0) {
            bootbox.confirm(' <%=GetLocalResourceObject("DeleteConfirm") %> ', function (confirmed) {
                if (confirmed == true) {
                    __doPostBack('btnDelete', 'OnClick');
                }
            });
        }
        else {
            bootbox.alert('<%=GetLocalResourceObject("NoSelectionAlert")%>');
        }

    });
});
 
Share this answer
 
Comments
VICK 19-Jun-14 7:43am    
then call server side function by using __doPostBack('btnDelete', 'OnClick');

Can you expalin it a bit further??

How to call the server side function??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900