Bootbox确认:返回客户端结果以便回发到rowCommand [英] Bootbox confirm: return client result in order to do postback to rowCommand
本文介绍了Bootbox确认:返回客户端结果以便回发到rowCommand的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< asp:Button ID =btnDeleteCssClass =btn btn-dangerOnClientClick =if(!confirmDelete())return false; runat =serverCommandArgument =<%#((GridViewRow)Container).RowIndex%> CausesValidation =falseCommandName =DeleteRowText =Delete/>
和js文件;
函数confirmDelete(){
return confirm(您确定要删除记录?); }
在确认的情况下,gridview的RowCommand被触发并且删除完成。 b
$ b
使用bootbox,我真的被卡住了。我知道bootbox是asynchronus并尝试使用'preventDefault',但它不起作用。那么如何将上述js文件转换为bootbox版本?
在此先感谢。
解决方案
我终于想出了这个解决方案;
函数confirmDelete(sender){
if($(sender).attr(confirmed)==true){return true;}
ootbox.confirm(你确定要删除?,功能(确认){
如果(确认){
$(发件人).attr(确认 ,确认).trigger(click);
}
});
返回false;
}
并更改按钮的OnClientClick;
OnClientClick =return confirmDelete(this);
Before bootbox, I did this on aspx file in gridview;
<asp:Button ID="btnDelete" CssClass="btn btn-danger" OnClientClick="if(!confirmDelete()) return false;" runat="server" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CausesValidation="false" CommandName="DeleteRow" Text="Delete"/>
and on js file;
function confirmDelete() {
return confirm("Are you sure you want to delete the record?"); }
And with confirmation, the gridview's RowCommand is triggered and the deletion is done.
With bootbox, I am realy stuck. I know bootbox is asynchronus and try to use 'preventDefault', but it didn't work. So how can I convert the above js file to bootbox version? Thanks in advance.
解决方案
I finally come up with this solution;
function confirmDelete(sender) {
if ($(sender).attr("confirmed") == "true") {return true;}
bootbox.confirm("Are you sure you want to delete?", function (confirmed) {
if (confirmed) {
$(sender).attr("confirmed", confirmed).trigger("click");
}
});
return false;
}
And changing button's OnClientClick;
OnClientClick="return confirmDelete(this);"
这篇关于Bootbox确认:返回客户端结果以便回发到rowCommand的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文