我想更换标准确认对话框。 我的javascript函数在这里
function checkDelete() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning", showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes Delete it!",
closeOnConfirm: false
},
function () {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
});
}
我如何在gridview templatefield按钮中使用甜蜜警报确认功能?
<asp:TemplateField ItemStyle-Width="60" HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lbDeleteUser" Runat="server" OnClientClick="checkDelete();" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
标准确认功能在这里
<asp:TemplateField ItemStyle-Width="60" HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lbDeleteUser" Runat="server" OnClientClick=" return confirm('Are you sure?');" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
标准确认功能正在运行。但甜蜜警报确认功能未运行。请帮忙
这是标准确认
播放帮助。
答案 0 :(得分:2)
使用此代码,它会帮助您
err
答案 1 :(得分:0)
不知道你的问题到目前为止是怎么回事,但这是我丑陋的解决方案。
function confirmBeforePostback(obj) {
var res = $(obj).attr('onclick').split(';');
if (res.length > 1) {
swal({
title: "Are you sure?",
text: "The will delete your record, are you sure?",
showCancelButton: true,
closeOnConfirm: true,
closeOnCancel: true
},
function (isConfirm) {
if (isConfirm) {
eval(res[1]);
}
});
}
return false;
}
在asp.net中,将代码添加到onclick属性中,如下例所示。
代码背后:
((Button)e.Row.Cells[5].Controls[2]).Attributes["onclick"] = "if(!confirmBeforePostback(this)) return false;";
或ASPX:
<ItemTemplate>
<asp:LinkButton ID="lbDeleteUser" Runat="server" OnClientClick="confirmBeforePostback(this);" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
答案 2 :(得分:0)
如果将来有人需要帮助,那么我用来实现这一点的代码片段。
byte buf[] = new byte[1024];
int len;
try {
Log.e(TAG, "Size of image on client side" + inputStream.readInt());
while ((len = inputStream.read(buf)) != -1) {
Log.e(TAG, buf + "");
out.write(buf, 0, len);
}
} catch (IOException e) {
Log.d(TAG, e.toString());
return false;
}
快乐的编码!