Reputation: 1376
I am opening the window like this
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);
I would like to close the window based on condition. I have tried so many ways like
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
my closeWindows function is
function CloseWindow() {
window.close();
}
If I call the function on onClientClick event, the popup is closing. But if I try to close it from code behind, the window is not closing. I have tried those three ways(I have commented in my code).
Upvotes: 1
Views: 942
Reputation:
Please review this solution in the link provided. http://forums.asp.net/t/993380.aspx?Close+Window+that+opens+with+window+showModalDialog as you will see the solution became:
<base target="_self">
Upvotes: 1