redirecting parent window when closing radwindow

3 posts, 1 answers
  1. dhlennon
    dhlennon avatar
    32 posts
    Member since:
    Oct 2006

    Posted 22 Feb 2013 Link to this post

    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>" 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. Answer
    Marin Bratanov
    Marin Bratanov avatar
    3908 posts

    Posted 25 Feb 2013 Link to this post


    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() {

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

    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.
  3. dhlennon
    dhlennon avatar
    32 posts
    Member since:
    Oct 2006

    Posted 15 Mar 2013 Link to this post

    thank you for your help Martin!
Back to Top