Question

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.

Was it helpful?

Solution

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

OTHER TIPS

function conformbox()
{
var con=confirm("Are you sure want to delete?");
if(con==true)
{
return true;
}
else
{
return false;}
}

-------------//*//----------------

<asp:Button ID="deleteBtn" runat="server" Text="Delete User" OnClientClick="return         
conformbox();" /><br />

check the return values (true or false)

Try this one

<div>
    <span onclick="return confirm('Are you certain you want to delete?');">
       <asp:Button ID="btnDelete" UseSubmitBehavior="false" runat="server" Text="Remove" 
            CssClass="appdl" CommandName="Remove" OnCommand="AppsList_ItemCommand"         
            CommandArgument='<%# Eval("ID") %>' />
      </span>
<div/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top