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

close rad window on another radwindow

5 Answers 162 Views
Window
This is a migrated thread and some comments may be shown as answers.
JJ
Top achievements
Rank 1
JJ asked on 03 Oct 2011, 09:22 PM
Thanks. The example helps.

5 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 04 Oct 2011, 01:21 PM
Hi J J,

I am not sure how exactly you are calling this method, but I advise that you examine the following help article on executing a JavaScript function from the server: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html.

I have also attached a simple page that opens a RadWindow from a RadWindow and closes the second one from within via a JS function call from the code-behind. You can compare it with yours and try to locate any major differences.


Regards,
Marin
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
JJ
Top achievements
Rank 1
answered on 04 Oct 2011, 08:51 PM
Hi Marin,

Thank you very much for the example, it helps.
One question: How can I make the first radwindow refersh after the second radwindow OnclientClose (use he "X" to close)

I put hte following on the first radwindow but give me error "OnClientClose2 not defined", this one works on the first radwindow.

function

 

 

OnClientClose2(sender, eventArgs) {

 

top.location.href = top.location.href;

}

function OnClientClose2(sender, eventArgs) {
             top.location.href = top.location.href;     
        }
  
 <telerik:RadWindowManager ID="custFileHistWindowMgr" runat="server" IconUrl="/img/radwindowicon.gif"
            Style="z-index: 7001">
            <Windows>
                <telerik:RadWindow ID="wndNewFileReq" runat="server" Modal="true" KeepInScreenBounds="true"
                    Height="450px" Width="700px" Animation="Fade" AutoSizeBehaviors="Default" ShowContentDuringLoad="true"
                 OnClientClose="OnClientClose2"    VisibleStatusbar="false" Behaviors="Close,Move" NavigateUrl="/DataFiles/NewFileRequest.aspx" />
            </Windows>
</telerik:RadWindowManager>
Thanks!
0
Marin Bratanov
Telerik team
answered on 05 Oct 2011, 10:37 AM
Hello J J,

The top.location.reload() (which is essentially the same as copying the href) would reload the entire page. What you need to do is:

1) get a reference to the desired RadWindow in its OnCilentClose event (which should be declared in the parent page of the RadWindow you just closed).
This can be done either via the $find() method, or via the RadWindowManager's getWindowByName method if your RadWIndows are in the the Windows collection of a RadWindowManager. With this I am assuming that your project structure is like my demo - a parent page with both RadWindows declared in it, so you can access them both from this page. This is where the OnClientClose handlers should be declared

2) Then you can call its reload() method so that the page is refreshed (please note that the page needs to be from the same domain for this to work, this is a generic JavaScript limitation). More information on the matter is available in the RadWindow's Client-side API reference.

Greetings,
Marin
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
JJ
Top achievements
Rank 1
answered on 07 Oct 2011, 08:18 PM
On your default.aspx example, I added the following:
function OnClientClose(sender, args) {
         alert('here');
         GetRadWindow().close();
         GetRadWindow().reload();
     }
But alert 'here" doesn't even triggered. is there anything I understand wrong? Thanks.
0
Marin Bratanov
Telerik team
answered on 10 Oct 2011, 01:48 PM
Hi J J,

In which page have you placed this function? It should be placed in Default.aspx as this is where the RadWindows "live". What I see is that you call the GetRadWindow() function as well, so I am inclined to think you have placed it in one of the pages, loaded within the RadWindows. If so - then there is no way for the parent page to call this handler, as it is in another document.

A handler should be placed in the page that hosts the control and you also have a reference to the said control as the first parameter passed to the handler, so you should use it instead of the GetRadWindow() function.

Please also make sure that you have attached the handler to the event - as seen in the markup of the second RadWindow in my example. You can also add event handlers via JavaScript as shown here.

Please examine the attachment to this post - the previous project with the added close handler, as it seems to be working as expected on my end: http://screencast.com/t/EVhHXVlqID. Please also note my comments in the code.


Best wishes,
Marin
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
Tags
Window
Asked by
JJ
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
JJ
Top achievements
Rank 1
Share this question
or