Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

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: 3.1/5 (7 votes cast)