Displaying "Are you sure?" alert before firing a server-side button
Posted on 2004-09-14
I have a "Delete Record" button. I want to give the user a chance to confirm his intentions before deleting the record, and would like to display a message box with "Are you sure?" and OK/Cancel. If the user presses OK the delete button posts back to the server, otherwise no further action is taken.
I know you can use the onclick event in hyperlinks, returning 'false' prevents the redirection. How do I do it with a server-side ASP.NET button?
I tried putting the following in the PageLoad event, but it didn't even display the message: