Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I wanted to some code when he clcik ok button . how do we write for that. Please help me

ScriptManager.RegisterStartupScript(this, this.GetType(), "ajax", "<script language='javascript'>confirm('Do u wanna change?');</script>", false)
if(clicked ==yes)
{
//do somthing
}
else
{
//do smthing
}
Posted

 
Share this answer
 
v2
Comments
kishorekke 29-Sep-11 5:46am    
But i want to operate this from code window. Please suggest me
member60 29-Sep-11 5:55am    
u can call the confirm function in .cs by using ScriptManager.RegisterStartscript (this,this.GetType(),"aa",<script language="javascript">if(confirm("xyz")){...}else{...})</script>
C#
ScriptManager.RegisterStartupScript(this, this.GetType(), "ajax", "<script language="javascript">if(confirm('Do u wanna change?')){ //do somthing } else { //do smthing } </script>", false)


try this
 
Share this answer
 
hi
you can try my code for displaying and processing using javascript.

JavaScript
<script language ="javascript" >
    function delval() {
        if (confirm("Do you want to delete")) {
            $.post("default16.aspx?action=delete", { id: "4" }, function (data) {
                //show results in tags
            });
        }
        else {
           //do nothing
        }
    }
</script>


And for your requirement you can not interrupt processing untill second request comes

Because every request from user serves as a new request.
we can not wait response from that confirm msg

Use Jquery to check confirm msg it'll get best experience to you for achieving your requirement.

All the Best
 
Share this answer
 
try with fillowing code
C#
<asp:Button runat="server" ID="Save" OnClientClick="if (!confirm('Are you sure?')) return false;" /> 
 
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