我已经搜索了 SO & google,但我似乎无法让它工作。该代码位于我的 asp.net 应用程序中“取消”按钮的代码隐藏单击事件中,但似乎没有关闭弹出窗口。有任何想法吗?
try
{
if (btnCancel.Text == "Close")
{
String csName1 = "PopupScript";
Type csType = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsClientScriptBlockRegistered(csType, csName1))
{
ClientScript.RegisterStartupScript(GetType(), "ClosePopup", "window.close();", true);
}
}
}
更新:回发后,当我查看源页面时,我看到的唯一相关代码是:
//<![CDATA[
(function() {var fn = function() {$get("ToolkitScriptManager1_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();window.close();
document.getElementById('ValidationSummary1').dispose = function() {
Array.remove(Page_ValidationSummaries, document.getElementById('ValidationSummary1'));
}