Click here to Skip to main content
15,887,815 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an a web application which have a button that will open an iframe form windows.

open.aspx is the button click

supervisor.aspx is the page open using iframe

the open.aspx
ASP.NET
<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)


ASP.NET
<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.

this is my supervisor.aspx.cs

C#
  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? for now I use a button click to close and I want to avoid less clicking.


Thanks in advance

What I have tried:

I have try using javascript but the iframe still won't close although the function works.
I following this link
https://stackoverflow.com/questions/43527062/how-to-close-window-after-iframe-form-submits and also https://stackoverflow.com/questions/29258881/close-iframe-from-another-webpage-asp-net
Posted
Updated 8-Dec-19 17:50pm
v2
Comments
F-ES Sitecore 5-Dec-19 4:58am    
You mean you want to eliminate the need to click the button, you want it to happen as you type? I'd advise against that as it will be jarring for the user, they are typing and suddenly something disappears and they won't know why.

If I was you I'd ditch the whole iframe business. Use a normal div with your textbox on the page then use something like jQuery to attach to the keyup even on the textbox and send an ajax query to a page method to do the validating of the text. The webmethod will return json that says if the text was correct or not, and if it was your jQuery code will then hide the div with your textbox.
Member 14659146 9-Dec-19 0:14am    
Thanks man I already found the solution here. Thanks again for suggessting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900