我的页面上有一个图像按钮。当我点击它时,我带来了确认:
function confirmDelete() {
if (confirm('Do you really want to delete this Image?') == true) {
return true;
}
else {
return false;
}
}
当用户点击" Ok"在confirmmbox上,它从数据库中删除记录并回复。我想要做的是在点击&#34之后调用以下函数; Ok"确认按钮:
function imageViewerTool() {
$("#overlay").show();
$("#imageViewerDialog").fadeIn(300);
}
我的图片按钮:
<asp:ImageButton ID="imgParts" runat="server" OnClientClick="return confirmDelete();" />
代码背后:
db.ExecuteNonQuery(CommandType.Text, "delete from tblTest where ImageName='img_1111'");
答案 0 :(得分:2)
function confirmDelete() {
if (confirm('Do you really want enter code here`o delete this Image?')) {
imageViewerTool(); // THIS
return true;
}
else {
return false;
}
}
答案 1 :(得分:0)
我已经更新了我的代码,现在可以使用了。
JavaScript的:
function confirmDelete() {
if (confirm('Do you really want to delete this Image?') == true)
return true;
else
return false;}
$(document).ready(function () {
var checkConfirm = document.getElementById("ctl00_ContentPlaceHolder1_hdnCheckConfirmBox").value;
if (checkConfirm != null && checkConfirm == "yes") {
imageViewerTool();
}});
function imageViewerTool() {
$("#overlay").show();
$("#imageViewerDialog").fadeIn(300);}
function HideImageViewerDialog() {
$('input:hidden[name="ctl00$ContentPlaceHolder1$hdnCheckConfirmBox"]').val('no');
$("#overlay").hide();
$("#imageViewerDialog").fadeOut(300);}
客户端:
<asp:LinkButton ID="lnkClose" runat="server" OnClientClick="HideImageViewerDialog();">Close</asp:LinkButton>
<asp:ImageButton ID="imgParts" runat="server" OnClientClick="return confirmDelete();" />
<asp:HiddenField ID="hdnCheckConfirmBox" runat="server" Value="no"/>
服务器端:
db.ExecuteNonQuery(CommandType.Text, "delete from tblTest where ImageName='img_1111'");
hdnCheckConfirmBox.Value = "yes";