提交代码后从另一个页面关闭 iframe



我有一个Web应用程序,它有一个按钮可以打开iframe表单窗口。

打开.aspx是按钮点击

主管.aspx是使用 iframe 打开的页面

开放.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>  

这是主管.aspx(iframe(

<asp:TextBox ID="inputid" runat="server" Font-Size="14px" ></asp:TextBox>  
<asp:Button ID="Button3" runat="server" Text="Uncheck"  OnClick="btnCheck_Click"  />  

如果用户输入正确的用户名,我希望 iframe 自动关闭。

这是我的主管.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!");
}

如果主管为 true,如何自动关闭 iframe? 现在我使用按钮单击来关闭,我想避免减少点击。

我尝试使用 javascript,但尽管该功能有效,但 iframe 仍然无法关闭。 我点击此链接 如何在 iframe 表单提交后关闭窗口,并从另一个网页关闭 iFrame + asp.net

谢谢

我从 asp.net 的Yu永清(https://forums.asp.net/members/Yongqing%20Yu.aspx(那里得到了指导,建议我在iframe页面上创建一个js方法,调用iframe页面的父层,然后隐藏ModalPopupExtender控件和面板控件。

这是线程

https://forums.asp.net/p/2162174/6287081.aspx?Re+Close+iframe+from+another+page+in+code+behind

最新更新