我现在有一个通过 javascript 运行的删除功能。您选择网格上的行,点击删除按钮 1,它会弹出一个包含删除按钮 2 的弹出窗口。单击删除按钮 2 会在连接到我的 c# 代码的不可见按钮上触发 .click 事件以进行删除。
在我将不可见按钮设置为 asyncpostbacktrigger 之前,这一切都可以正常工作。现在删除按钮 2 运行隐藏弹出命令,但不会触发 .click 事件。任何想法为什么?
资源
<script type="text/javascript">
//execute popup
function popup() {
$("#popupbg").animate({ opacity: ".8" });
$("#delete, #update").click(
function() {
var id = $(this).attr("id")
{
if (id == "delete") {
$("#popupbg, #lidelete, #butdelete, #butcancel").show('fast');
}
else if (id == "update") {
$("#popupbg, #liupdate, #butupdate, #butcancel").show('fast');
}
}
});
}
//execute popup cancel
function popupcancel() {
$("#popupbg, #liupdate, #butupdate, #butcancel, #lidelete, #butdelete").hide('medium');
}
//execute popup delete
function popupdel() {
var button = document.getElementById("execdelete");
button.click();
$("#popupbg, #lidelete, #butdelete, #butcancel").hide('medium');
}
//execute popup update
function popupupdate() {
var button = document.getElementById("execupdate");
button.click();
$("#popupbg, #liupdate, #butupdate, #butcancel").hide('medium');
}
</script>
<div id="popupbg">
</div>
<div id="popupbgitembg">
<ul class="popupbgitems">
<li id="lidelete">
Are you sure you want to delete?
</li>
<li id="liupdate">
Are you sure you want to update?
</li>
<li></li>
<li>
<input type="submit" name="execdelete" value="" id="execdelete" class="invisible" />
<input type="submit" name="execupdate" value="" id="execupdate" class="invisible" />
<input type="submit" name="butupdate" value="Yes" onclick="javascript:scroll;popupupdate();" id="butupdate" style="font-size:11px;width:70px;" />
<input type="submit" name="butdelete" value="Yes" onclick="javascript:scroll;popupdel();" id="butdelete" style="font-size:11px;width:70px;" />
<input type="submit" name="butcancel" value="No" onclick="javascript:popupcancel();" id="butcancel" style="font-size:11px;width:70px;" />
</li>
</ul>
</div>
<li class="lblinfo"><span id="lblGLDeptData"></span></li>
<li><input type="submit" name="update" value="Update" onclick="javascript:popup(); ;" id="update" style="width:70px;font-size:11px" />
<input type="submit" name="delete" value="Delete" onclick="javascript:popup();" id="delete" style="width:70px;font-size:11px" />
</li>
</ul>
</div>
</div>
<div id="gvMappingupdate">
<div id="headerdiv">
</div>
<div id="topcontentcover"></div>
<div class="topcontent">
<div>
</div>
<input type="submit" name="btnGetGLDept" value="" id="btnGetGLDept" class="invisible" />
<div id="gvMappingprogress" style="display:none;">
<div class="load"><img src="Images/loading.gif" alt="Loading" /></div>
</div>
javascript
function popup() {
$("#popupbg").animate({ opacity: ".8" });
$("#delete").click(function() {
$("#popupbg, #popupbgitembg").show('fast')
});
}
function popupcancel() {
$("#popupbg, #popupbgitembg").hide('medium');
}
function popupdel() {
var button = document.getElementById("<%= execdelete.ClientID %>");
button.click();
$("#popupbg, #popupbgitembg").hide('medium');
}
html
<div id="popupbg">
</div>
<div id="popupbgitembg">
<ul class="popupbgitems">
<li>
Are you sure you want to delete?
</li>
<li></li>
<li>
<asp:Button ID="execdelete" runat="server" CssClass="invisible" OnClick="delSysGLDepts" />
<asp:Button ID="butdelete" runat="server" Text="Delete" OnClientClick="javascript:scroll;popupdel();" Font-Size="11px"/>
<asp:Button ID="butcancel" runat="server" Text="Cancel" OnClientClick="javascript:popupcancel();" Font-Size="11px"/>
</li>
</ul>
</div>
我的异步回帖的一部分
</asp:UpdatePanel>
<%--Mapping Top Content --%>
<asp:UpdatePanel ID="gvMappingupdate" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="mapsearch" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="execdelete" EventName="Click" />
</Triggers>
<ContentTemplate>