我有一个asp.netlinkbutton
,其中包含OnClientClick
属性,但是函数内OnClientClick
永远不会被调用,它直接跳转到OnClick
功能。
以下是我使用 LinkButton 的两种方式:
<asp:LinkButton ID="btn" CssClass="button" Text="Browse Thumbnail" runat="server"
OnClientClick="return confirm('Are you sure you want to delete?');">
</asp:LinkButton>
and:
<asp:LinkButton ID="lnkDelete" runat="server"
OnClientClick="return confirm('Are you sure you want to delete this slide?');"
CommandName="DeleteThumbnail" CommandArgument='<%# Container.DataItemIndex %>'>
<asp:Image ImageUrl="~/images/delete.gif" ID="imgDelete" runat="server"></asp:Image>
</asp:LinkButton>
这两种方法都行不通。
任何人都可以提供一些解决方案吗?
OnClientClick="javascript:return confirmAction();"
function confirmAction() {
if(confirm('Are you sure you want to delete?')) {
// you clicked the OK button.
// you can allow the form to post the data.
return true;
}
else {
return false;
}
}
在服务器端实现Onclick
protected void lnkdelete_Click(object sender, EventArgs e)
{
}
如果您不想调用服务器方法,请使用此方法
OnClientClick="javascript:confirmAction(); return false;"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)