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

Trying to fire OnClientClose to execute window.location

3 Answers 56 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ivan
Top achievements
Rank 1
Ivan asked on 24 Sep 2010, 05:45 PM
Hi everyone.

I've been searching and looking around and I'm still having problems with this.

I have a button that opens a RadWindow where the user types comments, clicks an OK button to close the window, and then the original window should redirect to the main menu.

I've tried doing this with another window and just clicking the Close button on the window, with no luck.

Here is my code:

    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            //<![CDATA[
            function openRejWin() {
                var oWnd = radopen("Confirm.aspx", "RadWindow3");
            }
            function OnRejectedClose(sender, eventArgs) {
                alert("Moving on!");
                window.location = "Menu.aspx";
            }
            function OnClosing(sender, eventArgs) {
                alert("Closing!");
            }
            //]]>
        </script>
    </telerik:RadScriptBlock>
  
    <telerik:RadWindowManager ID="RadWindowManager1" VisibleStatusbar="false"
        runat="server" Skin="Hay" EnableShadow="true" >
        <Windows>
            <telerik:RadWindow ID="RadWindow3" runat="server" ReloadOnShow="true" Behaviors="Close" OnClientClose="OnRejectedClose"  
                OnClientBeforeClose="OnClosing" NavigateUrl="Confirm.aspx" DestroyOnClose="false">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
  

Then, the .cs code for the button does the following:

btnReject.Attributes.Add("onclick", "openRejWin(); return false");

The window does open, and it does close, but I don't see the alert messages and I don't get redirected to the Menu page.

Thank you for your help.

3 Answers, 1 is accepted

Sort by
0
Ivan
Top achievements
Rank 1
answered on 25 Sep 2010, 12:24 AM
I tried this on a new project and it works, so as soon as I find the reason why it doesn't work on my current project I will post it here.
0
Georgi Tunev
Telerik team
answered on 27 Sep 2010, 05:29 AM
Hello Ivan,


A problem like the one you describe, can occur if you have more than 1 RadWindowManager on the page. In such case, you need to take into consideration the following:

   1. All RadWindowManager's functions (radopen, radalert, radconfirm, radprompt, GetRadWindowManager, etc) are always using the first rendered RadWindowManager on the page.
   2. Every RadWindowManager "knows" only the RadWindows that are declared in its Windows collection.

This means that if you have a RadWindow2 declared in RadWindowManager2, and you use something like radopen(myUrl, "RadWindow2");, radopen will use RadWindowManager1 and will open a new RadWindow with the settings taken from RadWindowManager1. To avoid that problem, when you have multiple managers on a page, you need to get a reference to the correct RadWindowManager first and then call its methods.
e.g.
var manager = $find("<%= RadWindowManager2.ClientID %>");
manager.open(myUrl, "RadWindow2");


Best wishes,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ivan
Top achievements
Rank 1
answered on 27 Sep 2010, 03:18 PM

Looking at the code in more detail it turns out that I originally had 2 RadWindows on the same RadWindowManager. I tried the code on another page with only 1 RadWindow and it worked.

 

Thank you very much for your help.

 

Ivan.

Tags
Window
Asked by
Ivan
Top achievements
Rank 1
Answers by
Ivan
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or