I want to show the confirmation box in asp.net from server side:
I want to call it from server side because I have to take the customer message from server side. I am using the below code
string str = "Are you sure, you want to Approve this Record?";
ClientScript.RegisterStartupScript(typeof(Page), "Popup", "return confirm('" + str + "');",true);
// More code ....
Now it is showing the popup and irrespective of what I click, whether "ok" or "Cancel", my code is executing.
Please let me know how can I restrict code to be executed when user select "cancel" in the confirmation box.
Check it out:
CODE BEHIND:
string str = "Are you sure, you want to Approve this Record?";
this.ClientScript.RegisterStartupScript(typeof(Page), "Popup", "ConfirmApproval('" + str + "');", true);
ASPX:
function ConfirmApproval(objMsg)
{
if(confirm(objMsg))
{
alert("execute code.");
return true;
}
else
return false;
}