1

I would like to be able to delete a record from within an Asp.Net FormView ItemTemplate using an Asp button and an inline javascript confirm function.

The javascript works, I see the confirm dialog, when I click either button in the dialog, a postback does occur, but the record does not get deleted.

So far I have:

<asp:Button runat="server" 
     ID="btnDelete" 
     CssClass="NavigatorButton"    
     Text="Delete" 
     CausesValidation="true" 
     UseSubmitBehavior="false" 
     Visible="false" 
     CommandName="Delete" 
     OnClientClick="return confirm('This action will delete this provider note. Are you sure you wish to continue?');" />

The Delete works fine when I take the OnClientClick off the button, but I need the confirmation.

The javascript confirm works fine in the EditItem template.

Any ideas?

TrevorBrooks
  • 3,590
  • 3
  • 31
  • 53

1 Answers1

0

The confirm should only return a value if the user cancels out of the dialog else the page will not validate and postback.

See this stack overflow post about it.

Community
  • 1
  • 1
Ross Bush
  • 14,648
  • 2
  • 32
  • 55