Popup close & redirect

Posted on 2006-03-21
Last Modified: 2011-04-14
If I run into an error in a popup while processing VB.Net code on page_load, how can I redirect the main window that opened the popup to an error page and close the popup window? I'm not having much luck doing this from (2005 if it matters).
Question by:JeepGeekin
    LVL 26

    Expert Comment

    u will have to render a client side script for redirecting ur main page and then closing the current window .. use Page.RegisterClientScriptBlock

    Dim scriptString As String  = "<script language=JavaScript> parent.document.location.href = 'ErrorPage.aspx';"
    scriptString += "window.close();"
    scriptString += "</script>"

    Me.RegisterClientScriptBlock("ClientScript", scriptString)


    LVL 10

    Expert Comment

    plz find the following link


    Author Comment

    Thanks. Sorry. I moved on to another problem & forgot I posted this.
    Rejo. To test it, I added your code to the Page_Load of an aspx popup page & called the popup page from another page.

    What happened was that the popup closed, but the page that called it didn't do anything. I can's say I follow this enough to troubleshoot it. I guess Parent in a popup window is the calling page. Does anything else need to be done here between these 2 pages? I'll bump this up 100 points.

    SystemExpert, thanks, but that link didn't help me. It was for opening a popup from another popup & redirects within the popup window.
    LVL 26

    Accepted Solution

    try ..
    window.opener.document.location.href = 'ErrorPage.aspx'

    Author Comment

    That did it. Thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now