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

Closing and refeshing a page upon leaving a RadWindow

2 Answers 83 Views
Window
This is a migrated thread and some comments may be shown as answers.
Chad Johnson
Top achievements
Rank 1
Chad Johnson asked on 24 Nov 2008, 07:27 PM
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 Answers, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 24 Nov 2008, 09:03 PM
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. :)

0
Chad Johnson
Top achievements
Rank 1
answered on 24 Nov 2008, 09:07 PM
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
Tags
Window
Asked by
Chad Johnson
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
Chad Johnson
Top achievements
Rank 1
Share this question
or