Delete confirmation before delete Or Yes/No confirmation in asp.net

Introduction: It is always great idea to ask before delete e.g. sometimes by mistake you can press the delete button that can delete important records from your website so its always suggested that there should be confirmation to delete before deletion of any record.
  • Place a button control on the design page(.aspx)  and write as:

C#.Net Code

<asp:Button ID="btnDelete" runat="server" Text="Delete"
CausesValidation="False"
onclientclick="return confirm('Are you sure you want to delete?')" />

VB.Net Code

<asp:Button ID="btnDelete" runat="server" Text="Delete" CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete?')" />


Note: Now whenever you click on delete button it will prompt the confirmation of deletion. If you confirm Then code to delete record will get executed otherwise not.


Previous
Next Post »

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..