OnCommand不触发后OnClientClick返回确认
本文关键字:OnClientClick 返回 确认 OnCommand | 更新日期: 2023-09-27 18:02:20
我有这个删除函数,它工作得很好。我想在用户决定删除它之前添加一个确认,但是现在我的删除在用户从确认框返回OK后不起作用。
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>
正如您在上面的HTML中看到的,我使用OnCommand来执行删除功能。在我添加OnClientClick后,OnCommand似乎停止射击,即使在我单击OK之后。我不知道怎么了。如有任何指示,不胜感激。
将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 />
检查返回值(true或false)
试试这个
<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/>