How to display a confirm box while deleting an item in Gridview?

Confirm delete for GridView's Link Button using JavaScript

Here is the code using 2.0

<script type="text/javascript">

function confirm_delete()


if (confirm("Are you sure you want to delete the contact?")==true)

return true;


return false;



<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"


<asp:BoundField DataField="ID" SortExpression="ID" HeaderText="ID" />

<asp:BoundField DataField="Name" SortExpression="Name" HeaderText="Name" />

<asp:BoundField DataField="City" SortExpression="City" HeaderText="City" />

<asp:TemplateField HeaderText="Delete">


<asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete" Text="Delete"
OnClientClick="javascript : return confirm('Do you really want to \ndelete the





No comments: