Delete confirmation from asp:ImageButton

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.
naveenrajAsked:
Who is Participating?
 
Abirami RajendranCommented:

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)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.