ASP.NET: Add a confirmation popup to a Button
From Wiki
Summary: Ask the user for confirmation when they click a button
Need help with ASP.NET? Come and ask a question in our ASP.NET Forum
- <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return confirm('Are you sure you want to delete this record?');" />
Alternatively, you can add the confirmation message from your code-behind file in the Page Load event:
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Button1.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this record?');")
- End Sub
This Hack is part of the ASP.NET Hacks collection


