We help IT Professionals succeed at work.

Popup close & redirect

JeepGeekin asked
Medium Priority
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 VB.net (2005 if it matters).
Watch Question

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)


plz find the following link




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.
try ..
window.opener.document.location.href = 'ErrorPage.aspx'

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


That did it. Thanks!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.