[英]close iframe from another page after submit code behind
I have an a web application which have a button that will open an iframe form windows.我有一个 Web 应用程序,它有一个按钮可以打开 iframe 窗体窗口。
open.aspx is the button click open.aspx 是按钮点击
supervisor.aspx is the page open using iframe supervisor.aspx 是使用 iframe 打开的页面
the open.aspx open.aspx
<div style="vertical-align: middle; text-align: center; left: 500px; width: 122px; position: absolute; top: 560px; height: 50px; z-index: 126; right: 889px; font-size: 50pt; font-family: Calibri; font-weight: bold;" id="uncheckbutton">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="UNCHECK" />
//this is the onclick button to open the iframe
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" TargetControlID="Button1"
CancelControlID="Button2" BackgroundCssClass="Background">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panl1" runat="server" CssClass="Popup" align="center" style = "display:none">
<iframe style=" width:400px; height: 150px;" id="irm1" src="Uncheck popup.aspx" runat="server"> </iframe>
<asp:button Top="100px" id="button2" runat="server" text="CLOSE" />
</asp:Panel>
and this is the supervisor.aspx(the iframe)这是supervisor.aspx(iframe)
<asp:TextBox ID="inputid" runat="server" Font-Size="14px" ></asp:TextBox>
<asp:Button ID="Button3" runat="server" Text="Uncheck" OnClick="btnCheck_Click" />
if the user enter the correct username, i want the iframe to automatically close.如果用户输入正确的用户名,我希望 iframe 自动关闭。
this is my supervisor.aspx.cs这是我的主管.aspx.cs
protected void btnCheck_Click(object sender,EventArgs e)
{
string uncheck = inputid.Text;
bool supervisor = Cls.GetUncheckSupervisor(uncheck);
if (supervisor==true)
{
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "window.close()",
.true);
}
else
{
Show("Wrong ID!");
}
if the supervisor is true, how can I automatically closed the iframe?如果supervisor是真的,如何自动关闭iframe? for now I use a button click to close and I want to avoid less clicking.
现在我使用按钮点击关闭,我想避免点击次数减少。
I have try using javascript but the iframe still won't close although the function works.我尝试使用 javascript,但 iframe 仍然不会关闭,尽管该功能有效。 I following this link How to close window after iframe form submits and also Close iFrame from another webpage + asp.net
我按照这个链接如何在 iframe 表单提交后关闭窗口,并从另一个网页 + asp.net 关闭 iFrame
thanks谢谢
I got guide from Yongqing Yu ( https://forums.asp.net/members/Yongqing%20Yu.aspx ) from asp.net that suggest me to create a js method on the iframe page, call the parent layer of the iframe page, then hide the ModalPopupExtender control and panel control.我从asp.net 的Yongqing Yu ( https://forums.asp.net/members/Yongqing%20Yu.aspx ) 那里得到了指导,建议我在iframe 页面上创建一个js 方法,调用iframe 页面的父层,然后隐藏 ModalPopupExtender 控件和面板控件。
Here is the thread这是线程
https://forums.asp.net/p/2162174/6287081.aspx?Re+Close+iframe+from+another+page+in+code+behind https://forums.asp.net/p/2162174/6287081.aspx?Re+Close+iframe+from+another+page+in+code+behind
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.