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 ?
有没有办法通过点击弹出窗口的aspx文件中的服务器端按钮来关闭代码隐藏的模式弹出窗口?
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 ..
我发现代码可以在用户单击服务器端ASP.NET按钮时关闭非模态弹出窗口(即使用window.open(...)打开的窗口),但该代码不适用于Modal弹出窗口。
Also, no jQuery please, or any other 3rd party library ...
此外,没有jQuery请,或任何其他第三方库...
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 ..
此外,该解决方案只需要在Internet Explorer上工作,因为浏览器是在我们的域中使用的..如果解决方案不适用于Chrome,Firefox等,这是可以的。
Code used to raise the Popup:
用于引发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
这不是重复..相信我,我已经搜索了很多..所有其他问题都与非莫代尔弹出相关,就像我说的,我已经知道如何关闭
2 个解决方案
#1
1
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.
你应该考虑大卫的评论。好吧无论如何,你可以添加window.close();正如@CodeMonkeyForHire所说,并在点击事件结束时粘贴以下内容,您希望通过该事件关闭弹出窗口。
Response.Write("<script language='javascript'>self.close();</script>");
This should work.
这应该工作。
#2
0
window.close();
window.close()的;
Just return a script block with that in it.
只需返回一个脚本块即可。
#1
1
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.
你应该考虑大卫的评论。好吧无论如何,你可以添加window.close();正如@CodeMonkeyForHire所说,并在点击事件结束时粘贴以下内容,您希望通过该事件关闭弹出窗口。
Response.Write("<script language='javascript'>self.close();</script>");
This should work.
这应该工作。
#2
0
window.close();
window.close()的;
Just return a script block with that in it.
只需返回一个脚本块即可。