Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

ASP.NET: Add a confirmation popup to a Button

From Wiki

Jump to: navigation, search

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

  1. <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:

  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.     Button1.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this record?');")
  3. End Sub


This Hack is part of the ASP.NET Hacks collection

441 Rating: 5.0/5 (1 vote cast)