Search code examples
jquery.netiframepostbackcolorbox

Cloase iframe Colorbox with .Net submit button


I have a simple login form invoked for a colorbox link and opening in a iframe.

<script>
    $(document).ready(function () {

        $(".logincb").colorbox({iframe:true, innerWidth:240, innerHeight:200});

    });
</script>

<li><a href="/login/login.aspx" class="logincb">login</a></li>

The issue I have having is once the user has correctly entered there login details in the ifrmae, which is checked via a post back in the code behind how can I redirect the parent page and close the frame?


Solution

  • With using a .Net buttons in the form is all makes it a bit strange in the end what I did was include the following function in the page

      <script language="javascript" type="text/javascript">
    
            function closePage() 
            {
                parent.$.fn.colorbox.close(); parent.location = '/support/marketing-media.aspx';
            }
    
    </script>
    

    then called it in the code behind button event using the ClientScript manager.

      if (!ClientScript.IsStartupScriptRegistered("alert"))
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(),"alert", "closePage();", true);
                    }
    

    Not really a fan of this as its ugly, but it works..