Delete confirmation from asp:ImageButton

Posted on 2005-04-23
Last Modified: 2010-08-05
I would like to ask the user to confirm (yes/no) if they really want to delete this record after they have clicked the image button.

<asp:ImageButton runat="server" ImageUrl="images/imgDelete.gif" ToolTip="Delete" OnClick=""/>

How can I add code to the OnClick event to enable this confirmation. Do I need to use javascript also ? Can someone please show me an example. Preferred web language is (VB.NET). Thanks.
Question by:naveenraj
    1 Comment
    LVL 6

    Accepted Solution


    1) Give and ID for the image button (in this case ImageButton1)
    2) On ImageButton1_Click write the code for delete
    3) Add the following gode in Page_Load event

    Dim sConfirmMsg As String = "return confirm('Are you sure you want to delete?');"
    ImageButton1.Attributes.Add("onclick", sConfirmMsg)

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now