This is a migrated thread and some comments may be shown as answers.

redirecting parent window when closing radwindow

2 Answers 261 Views
Window
This is a migrated thread and some comments may be shown as answers.
dhlennon
Top achievements
Rank 1
dhlennon asked on 22 Feb 2013, 04:34 PM
Calling all brains!

I have a PayPal 'Buy Now' button in a radwindow. On clicking this button the radwindow closes, and the parent page redirects to PayPal. This all works fine.

My concern is how to deal with the delay between the radwindow closing, and the parent page processing its redirect.  To the user it seems nothing is happening for a few seconds. It might not be possible but has anyone a good idea on how to show a "please wait" type message on the parent? 

I am using an empty label "lblJavaScript" on the parent and

 

lblJavaScript.Text =

"<script type='text/javascript'>top.location.href='" & sPayPal & "';GetRadWindow().Close();</script>"

...in the radwindow (where sPayPal = the URL to redirect to).

This works fine.
If I had two <div> on the parent page, one for the content to see before the radwindow pop-up, and one to show when it closes, is there any way to change my javascript above to show the new div as well as redirect the page and close the window?

Sorry to be so dumb. I don't think you can do this, but if you never ask cleverer people you never know!

thanks so much folks




    

2 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 25 Feb 2013, 12:16 PM
Hello,

There isn't a universal way to do this. Once the main page is navigated to another URL it is up to the browser to start disposing the old page, so usually you can't rely on content from it. What I can suggest is two different options:
- create a hidden div (e.g. centered on the page) that will show the message. Also add a function that will show it and call that just before you redirect the browser. You could also add an anchor there and set it to the URL you redirect to so that the user can click that if it takes too long to load the page or the browser does not allow such redirects.
- create this message div in the RadWindow and show it in the RadWindow. You can probably do this in the server code by toggling the VIsible property of the given panel and the rest of the page. Then leave the browser to dispose the page when it can, without closing the RadWIndow. This will keep the message visible as long as the page is not disposed and the RadWindow will be closed by the fact that the page is disposed.

Here is a simple example of toggling a div in the RadWindow with JavaScript (where I assume the label that is used to execute the script is in the content page of the RadWindow):
lblJavaScript.Text = "<script type='text/javascript'>showMessageDiv(); top.location.href='" & sPayPal & "';</script>"

the script
function showMessageDiv() {
  document.getElementById("pleaseWaitMessageDiv").style.display=""
}

and the div:
<div id="pleaseWaitMessageDiv" style="display:none;" class="someClassForStyling">Please wait...redirecting</div>



Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
dhlennon
Top achievements
Rank 1
answered on 15 Mar 2013, 08:39 AM
thank you for your help Martin!
Tags
Window
Asked by
dhlennon
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
dhlennon
Top achievements
Rank 1
Share this question
or