Link to home
Create AccountLog in
Avatar of JeepGeekin
JeepGeekin

asked on

Popup close & redirect

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).
Avatar of Rejojohny
Rejojohny
Flag of United States of America image

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)

Rejo

Avatar of JeepGeekin
JeepGeekin

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Rejojohny
Rejojohny
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
That did it. Thanks!