title: Adding a JavaScript confirmation prompt to a delete command button in an ASP.NET grid view?
body: <p>So I have an ASP.NET grid view:</p>
  
  <pre><code>&lt;asp:GridView ID="gvReferences" runat="server" AutoGenerateColumns="False" ShowHeader="False"
      OnRowEditing="gvReferences_RowEditing" 
      OnRowDeleting="gvReferences_RowDeleting" onrowcreated="gvReferences_RowCreated"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField ItemStyle-Width="400px"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblId" Visible="false" runat="server" Text='&lt;%# Eval("Id") %&gt;' /&gt;
                  &lt;asp:Label ID="lblAssociatedSpecies" runat="server" Text='&lt;%# Eval("Text") %&gt;' /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblKind" runat="server" Text='&lt;%# Eval("Kind") %&gt;' /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:CommandField ButtonType="Button" DeleteText="delete" ShowDeleteButton="True"
              ShowCancelButton="False" EditText="edit" ShowEditButton="True"&gt;
              &lt;ControlStyle Width="60px" /&gt;
          &lt;/asp:CommandField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I'd like to attach some JavaScript to the <kbd>Delete</kbd> command button to ask for confirmation before a row is deleted.</p>
  
  <p>Any ideas?</p>