开发者

OnClientClick="return confirm('Are you sure you want delete');"

开发者 https://www.devze.com 2022-12-12 21:23 出处:网络
I am using this code for confirmation on deletion. When I click on the link button, it asks me for confirmation, but the first time I click OK, the record is not getting deleted (only for the first ti

I am using this code for confirmation on deletion. When I click on the link button, it asks me for confirmation, but the first time I click OK, the record is not getting deleted (only for the first time).

Thereafter that record gets deleted successfully.

<asp:LinkButton ID="LinkBtnDelete" runat="server" 
OnClientClick="return confirm('Are you sure you want delete');" 
CommandName="Delete">Delete 
</asp:LinkButton> 

Any help would be grea开发者_运维知识库t, thank you.


If the above answers doesn't workout for you then try below code:

<asp:LinkButton ID="LinkBtnDelete" runat="server" 
OnClientClick="if (!confirm('Are you sure you want delete?')) return false;" 
CommandName="Delete">Delete 
</asp:LinkButton>


<asp:LinkButton ID="LinkBtnDelete" runat="server" 
OnClientClick="return confirm('Are you sure you want delete');" 
CommandName="Delete" CommandArgument="">Delete 
</asp:LinkButton>

you must put CommandArgument so it will work from first time

0

精彩评论

暂无评论...
验证码 换一张
取 消