简体   繁体   中英

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.

从标记和try中删除UseSubmitBehavior="false"

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/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM