Delete Confirmation on ASP.NET page using CSLA

Delete Confirmation on ASP.NET page using CSLA

Old forum URL: forums.lhotka.net/forums/t/4637.aspx


CyclingFoodmanPA posted on Tuesday, April 08, 2008

Ok, I have been battling with this for a while.  I have seen how to add client-side confirmation when deleting on: http://www.asp.net/learn/data-access/tutorial-22-vb.aspx utilizing the DAL/BLL messy way of coding.  Hey, after learning Rocky's CSLA, going through the DAL/BLL tutorials seem primitave, however, they are excellent for learning the nuances of ASP.NET.  Anyway, has anyone done this and how did you do it?

Thank you in advance

Keith

 

JoeFallon1 replied on Tuesday, April 08, 2008

In a datagrid you could have a column of delete buttons.

Use mark up like this:

<ASP:TEMPLATECOLUMN HeaderText="Delete">
           <ITEMTEMPLATE>
             <SPAN onclick="return confirm('Do you really want to delete this record from the system?')">
                <ASP:IMAGEBUTTON id="btnDelete" runat="server" ToolTip="Delete" ImageUrl="~/img/delete.gif" CommandName="btnDelete"></ASP:IMAGEBUTTON>
              </SPAN>
            </ITEMTEMPLATE>
          </ASP:TEMPLATECOLUMN>

On an edit form it might look like this:

      <asp:button id="btnSave" runat="server" text="Save and Exit"></asp:button>
      <span onclick="return confirm('Do you really want to delete this record from the system?')">
         <asp:button id="btnDelete" runat="server" text="Delete"></asp:button>
      </span>
      <asp:button id="btnCancel" runat="server" text="Cancel"></asp:button>

Joe


CyclingFoodmanPA replied on Wednesday, April 09, 2008

Thank you Joe, that was it.  I just had to change my commandfield's to templates and it worked.

Keith

Copyright (c) Marimer LLC