When you try to delete a record, set of records you may want to confirm again to delete. If you delete a bunch of records accidentally by clicking a button all the data will be lost. You can add a javascript confirm box to any of the button’s onclick event or link’s onclick event to popup to confirm when you want to delete data.

For this example I have just added the onclick event to an anchor tag. The javascript in the event will return true if you click OK in the confirm box or return false if you click cancel. If the return value is true the page will redirected to the delete page. If the return value is false the page will not redirect. It is just a lind of code.


<a href="delete.aspx?id=1" onclick="return confirm('Are you sure you want to delete?')">Delete</a>