ASP.NET MVC - how to make users confirm the delete

Posted by H4mm3rHead on Stack Overflow See other posts from Stack Overflow or by H4mm3rHead
Published on 2010-03-29T11:25:14Z Indexed on 2010/03/29 11:33 UTC
Read the original article Hit count: 198

Filed under:

He, I have this page where i have checkboxes next to every item in a table, and want to allow the user to select some of them and press my delete button. I just cant come up with the jquery for making the confirm window and submitting only if 'yes' is pushed - this is my page

<%Html.BeginForm(); %>
<%List<ShopLandCore.Model.SLGroup> groups = (List<ShopLandCore.Model.SLGroup>)Model; %>
<%Html.RenderPartial("AdminWorkHeader"); %>
<table width="100%" id="ListTable" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="5" class="heading">
            <input type="submit" name="closeall" value="Close selected" />
            <input type="submit" name="deleteall" value="Delete selected" />
        </td>
    </tr>
    <tr>
        <th width="20px">
        </th>
        <th>
            Name
        </th>
        <th>
            Description
        </th>
        <th width="150px">
            Created
        </th>
        <th width="150px">
            Closed
        </th>
    </tr>
    <%foreach (ShopLandCore.Model.SLGroup g in groups)
      { %>
    <tr>
        <td>
            <%=Html.CheckBox(g.Id.ToString()) %>
        </td>
        <td>
            <%=g.Name %>
        </td>
        <td>
            <%=g.Description %>
        </td>
        <td>
            <%=g.Created %>
        </td>
        <td>
            <%=g.Closed %>
        </td>
    </tr>
    <%} %>
</table>
<%Html.EndForm(); %>

Please note that its only for the delete that it should confirm, and not necessarily for the close button.

© Stack Overflow or respective owner

Related posts about asp.net-mvc