Reputation: 13436
Is there a way to close a modal popup from code-behind, through the click of a server-side button that's on the popup's aspx file ?
I have found code which can close a non-modal popup (i.e. one opened using window.open(...)
) when user clicks a server-side ASP.NET button, but that code does not work on Modal popups ..
Also, no jQuery please, or any other 3rd party library ...
Also, the solution need only work on Internet Explorer, as that is the browser is that being used in our domain .. It's okay if the solution won't work on Chrome, Firefox, etc ..
Code used to raise the Popup:
<asp:Button ID="Button1" runat="server" Text="Button2" OnClientClick="basicPopup();return false;" OnClick="Button1_Click"/></td>
function basicPopup()
{
var strReturn = window.showModalDialog("TaxReportInputsForm.aspx", person,'status:no;dialogWidth:450px;dialogHeight:110px;dialogHide:true;help:no;scroll:yes');
if(strReturn.okpressed == true)
{
....
}
else
{
....
}
}
Note to all:
This is NOT a duplicate .. Believe me, I've searched far and wide .. All other questions are non-Modal popup related, which like I said, I already know how to close
Upvotes: 3
Views: 10750
Reputation: 436
You should consider the comments of David.
Well anyhow, you can add the window.close();
as said by @CodeMonkeyForHire and affix the following at the end of the click event by which you wish to close the popup.
Response.Write("<script language='javascript'>self.close();</script>");
This should work.
Upvotes: 1
Reputation: 362
window.close();
Just return a script block with that in it.
Upvotes: 0