admin管理员组文章数量:1220457
i have a asp:button that will fire a delete and want to have a client side javascript are you sure pop-up prevent any accidents.
whats the javascript to handle this?
i have a asp:button that will fire a delete and want to have a client side javascript are you sure pop-up prevent any accidents.
whats the javascript to handle this?
Share Improve this question asked Nov 18, 2010 at 20:27 kacalapykacalapy 10.1k20 gold badges77 silver badges121 bronze badges2 Answers
Reset to default 18You can add the javascript to the OnClientClick() event of the button... the key is to return false if you want to cancel the event. If you return false, the OnClick will not fire.
<asp:Button id="DeleteButton" runat="server" Text="Delete"
OnClick ="delete_clickhandler"
OnClientClick="return confirm('Are you sure you want to?');" />
Alternately, you can call a method in javascript
<asp:Button id="DeleteButton" runat="server" Text="Delete"
OnClick ="delete_clickhandler"
OnClientClick="return MyDeleteConfirm();" />
Where MyDeleteConfirm() does something more elaborate, but returns false if you don't want to delete.
This worked for me (the accepted answer did not)
<asp:Button id="DeleteButton" runat="server" Text="Delete"
OnClientClick="if (!confirm('Are you sure you want to delete?')) return false;">
</asp:Button>
本文标签: aspnet button click w javascript quotare you surequot prior to post backStack Overflow
版权声明:本文标题:asp.net button click w javascript "are you sure?" prior to post back - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739263137a2155465.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论