Search code examples
c#asp.neteventsonclientclick

OnCommand Not Firing After OnClientClick return confirm


I have this delete function that was working perfectly fine. Wanted to add a confirmation right before the user decides to delete it, but now my delete won't work after the user returns OK from the confirmation box.

HTML:

<div>
    <asp:Button ID="btnDelete" UseSubmitBehavior="false" runat="server" Text="Remove" 
        CssClass="appdl" CommandName="Remove" OnCommand="AppsList_ItemCommand" 
        OnClientClick="return confirm('Are you certain you want to delete?');"
        CommandArgument='<%# Eval("ID") %>' />
</div>

As you can see in the HTML above, I'm using OnCommand to perform the delete function. After I added in OnClientClick, OnCommand seems to stop firing, even after I click OK. Not really sure what's wrong. Any pointer would be very much appreciated.


Solution

  • remove UseSubmitBehavior="false" from your mark up and the try