Closing and refeshing a page upon leaving a RadWindow

3 posts, 0 answers
  1. Chad Johnson
    Chad Johnson avatar
    54 posts
    Member since:
    Sep 2012

    Posted 24 Nov 2008 Link to this post

    Greetings,

    Ok, so here is what's going on.  I'm using a RadGrid with a RadToolBar to display some data.  On the toolbar, I have a button called Deny Membership.  Upon clicking it, it pops up a RadWindow with two labels in it, along with a RadTextbox and an ASP:Button.  Upon clicking the button, the page does some database calls to delete a user out of a table.

    Ok, here is the part I'm having trouble with.  Once that is done, at the end of the Click Event, I have a label's (the first one on the page) text set to the following:

    lblReason.Text = "<script>RefreshParentPage()</" + "script>"

    That works fine, so the page starts that function as follows:

    <script type="text/javascript">  
                function GetRadWindow() {  
                    var oWindow = null;  
                    if (window.radWindow)  
                        oWindow = window.radWindow;  
                    else if (window.frameElement.radWindow)  
                        oWindow = window.frameElement.radWindow;  
                    return oWindow;  
                }  
     
                function RefreshParentPage()  
                {  
                    GetRadWindow().BrowseWindow.location.reload();  
                }  
            </script> 

    This is an example that I found on the Telerik site to close out a RadWindow and refresh the parent page.  The problem is, I get a javascript error on GetRadWindow().BrowseWindow, saying it is null or not an object.  I'm unsure what to do with this.  Any ideas?  Thanks.

    ~ Chad
  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 24 Nov 2008 Link to this post

    Hey Chad,

    This code works for me on my page:

                function GetRadWindow() {  
                    var oWindow = null;  
                    if (window.radWindow) oWindow = window.radWindow;  
                    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;  
                    return oWindow;  
                }  
     
                function Cancel_Clicked() {  
                    var oWindow = GetRadWindow();  
                    oWindow.close();  
                    top.location.href = top.location.href;                  
                } 

    Then you just set the Cancel_Clicked (or whatever more sensical thing you name it to) to your button, etc:

    <button onclick="Cancel_Clicked(); return false">Back to main page</button> 

    So instead of throwing a script, you could just call this function at the end of your click event and viola, it should work. :)

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chad Johnson
    Chad Johnson avatar
    54 posts
    Member since:
    Sep 2012

    Posted 24 Nov 2008 Link to this post

    Thanks for your reply, but unfortunately, I was looking to automatically close the page.  I did however come up with a solution with a touch of help from a coworker.  When I do RefreshParentPage(), I did the following.

    function RefreshParentPage()  
                {  
                    GetRadWindow().Close();  
                    parent.location.reload(true);  
                } 

    This just simply closes the window and refreshes the original page, which is what I needed done.

    ~ Chad
Back to Top