ASP.NET confirm before executing codebehind
Please try as follows. You have to return the result of the confirmation function (true or false).
<asp:Button ID="btnDelete" runat="server" Text="Delete" UseSubmitBehavior="false" OnClick="btnDelete_Click" OnClientClick="return confirmation();" />
function confirmation() { return confirm("Are you sure you want to delete?");}
Put this in your aspx code:
OnClientClick="return confirm('Are you sure you want to delete this project?');"
I know this is old post, but you can put the above answers into one line like this. And you don't even need to write the function.
<asp:Button runat="server" ID="btnDelete" Text="Delete" OnClick="btnDelete_Click" OnClientClick="if ( !confirm('Are you sure you want to delete ? ')) return false;" />