When opening the window, I follow this approach:
var MyArgs = new Array(ParmA, ParmB, ParmC, ParmD, ParmE, ParmF);
var leftpost = getWindow_TotalWidth() - 1000 - 100;
var WinSettings1 = "dialogHeight:580px; dialogWidth:950px;edge:Raised; center:Yes; resizable:No; status: No;dialogLeft:" + leftpost + ";dialogTop:253px";
var MyArgs = window.showModalDialog("../Accounts/LedgerAdd.aspx?LedgerCode=" + MyArgs[1].toString().split("~")[0] + "&Popup=1", MyArgs, WinSettings1);
However, closing the window based on a condition has proven to be more challenging. Various methods were attempted such as:
If Not Convert.ToDecimal(HidOpeningBalance.Value) = Convert.ToDecimal(TxtOpeningBalance.Text) Then
Dim LedgerID As Integer = Request.QueryString("LedgerCode")
Dim dtTransactionCount As DataTable = Grid.GetDataTable("sp_checkForAnyTransaction", LedgerID)
If dtTransactionCount.Rows.Count > 0 Then
LblError.Text = "You can not change Opening Balance after transactions made on this ledger."
Exit Sub
Else
Call FnUpdate()
Page.ClientScript.RegisterStartupScript([GetType](), "Javascript", "javascript:CloseWindow();", True)
End If
Else
LblError.Text = ""
Call FnUpdate()
Page.ClientScript.RegisterStartupScript([GetType](), "Javascript", "javascript:window.close();", True)
'Response.Write("<script language='javascript'>self.close();</script>")
'Page.ClientScript.RegisterStartupScript([GetType](), "Javascript", "javascript:CloseWindow();", True)
End If
The closeWindows function is defined as follows:
function CloseWindow() {
window.close();
}
While calling the function on onClientClick event successfully closes the popup, attempting to close it from code behind presents challenges. Multiple approaches were tested and commented in my code but none resulted in the desired closing of the window.