I've exhausted my search efforts on both SO and Google, but I'm still unable to get this particular code working. The issue lies within the codebehind click event of a "Cancel" button in my ASP.NET application. Despite my attempts, the popup window refuses to close. Any suggestions?
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);
}
}
}
Update: Upon inspecting the source page post-postback, I only see the following related code:
//<![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'));
}