Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code is -
C#
ScriptManager.RegisterStartupScript(upMB, this.GetType(), "script", "confirm('Are you proceed!');", true)

This works fine and displays confirm message.
My problem is, if the result of the confirm message is true, then I want to execute some code and if the result of confirm message is false I don't want the code to execute.

But at present in either case the code gets executed.

Can anyone help me out please.
Posted
v3
Comments
Sergey Alexandrovich Kryukov 25-Jul-12 1:27am    
ASP.NET, I presume? Tag it.
--SA

Hi,
You have to return the value from the function in the event handler:

C#
OnClientClick="return ConfirmDelete();"


By the way, you don't need all that logic in the function, just return the result from the confirm call:

C#
function ConfirmDelete() {
  return confirm("Are you SURE you want to delete this item?");
};




--Amit
 
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