Click here to Skip to main content
15,883,769 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

can any one tell me
how it is work. and how can I get OK or cancel buttons.

XML
string strconfirm = "<script>if(!window.confirm('On this Payment date " + DateTransaction + " there are " + countpayments + " are there. Do you want to Import any way?.'))</script>";
                          CSM.RegisterClientScriptBlock(this.GetType(), "Confirm", strconfirm, false);


Thank you
Posted
Comments
CodeBlack 26-Sep-13 9:45am    
what error you are facing ?

1 solution

Hey Sivarjun,

I know of two ways how you can go about this :
HTML
ConfirmSave()
     {        
        var Ok = confirm('Are you sure want to save the changes?');
         if(Ok)
             return true;
         else
             return false;
     }

 ---------------------------------------//For redirection to the URL
 

function ConfirmCancel(URL)
     {        
        var Ok = confirm('Are you sure want to Cancel the changes?');
         if(Ok == true)
         {
             document.location.href=URL;            
        }        
        //else
             //return false;
     }

In server side you can add this line for adding attributes of onclick()
HTML
btnSave.Attributes["onclick"] = "javascript:return ConfirmSave();";            
btnCancel.Attributes["onclick"] = "javascript:ConfirmCancel('InspectionNew.aspx');";


or you could try :

C#
if (true)
        {
            //Your code
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "open", "show();", true);
        }


and in your page :

HTML
<script type="text/javascript">
        function show()
        {
            if(confirm('r u sure?'))
            {
                window.location.replace('yourpage.aspx');
            }
        }
    </script>


Hope this helps.
 
Share this answer
 

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