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

Change parent location on client close

3 Answers 90 Views
Window
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 06 May 2011, 06:59 PM
I searched the forum and couldn't find anything that fixed my problem, so I'm posting it now in hopes of getting an answer. This is my problem: I am using RadWindow as a popup modal login. The window opens without any problems and I can perform the login without any problems. The issue is when the RadWindow closes. I keep getting an error saying that the javascript method is undefined. This is the relevant code:

<telerik:RadWindow ID="dlgLogin" runat="server" Behaviors="Close" ReloadOnShow="true" OnClientClose="RadWindowOnClientClose" BackColor="Gray" Modal="true" Height="250"></telerik:RadWindow>

function RadWindowOnClientClose(radWindow) {
                document.location.pathname = "/DaytonDefense/Web/Public/Default.aspx";
            }

Now when I change the inside of the function to something like 'window.location.reload' it works without any problems. Also, if I put that line inside another function and call it from a button click it works fine as well, it just won't work in the OnClientClose function. I can't figure out what I'm doing wrong, help please!

3 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 06 May 2011, 08:11 PM
I finally figured out how to achieve what I wanted. For some reason you cannot use location.href, location.pathname, or anything like that inside the OnClientClose event. The solution can be found here: http://www.telerik.com/community/code-library/aspnet-ajax/window/using-r-a-d-window-for-a-login-form.aspx. Basically you write a script to the text of a label on the login page to change the pathname or href or whatever you want. Just make sure that your function to close the window (GetRadWindowManager().Close()) comes before the label you place on the page, otherwise it will be undefined.
0
Accepted
Marin Bratanov
Telerik team
answered on 09 May 2011, 03:17 PM

Hello Andrew,

This Code Library is for the ASP.NET Classic version. In the latest version of the RadControls for ASP.NET AJAX there are no such limitations. You can find a simple test page attached and here is a video from my experiment: http://screencast.com/t/LVdMJ0O1. Please note that the path I set is specific to my test project, but changing it to your custom one should not make a difference.

Without your actual code I can only be guessing, but the most likely cause for the error is that you load an external page in the RadWindow and you have defined the JavaScript function there instead of on the main page. In that case the external page is loaded in an iFrame and thus is not actually part of the main page.

If you are still experiencing difficulties please open a support ticket and send us a simple, fully runnable project that displays the issue, so we can investigate it further. Please note that we do not need your actual login logic, database, etc, just a mock-up that displays the issue.



Regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Andrew
Top achievements
Rank 1
answered on 10 May 2011, 07:54 PM
That was my exact problem. I moved the javascript code to the main page that the RadWindow resides on, as per your example, and it all works fine now.

Thanks!
Tags
Window
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or