Trying to fire OnClientClose to execute window.location

4 posts, 0 answers
  1. Ivan
    Ivan avatar
    9 posts
    Member since:
    Sep 2010

    Posted 24 Sep 2010 Link to this post

    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.
  2. Ivan
    Ivan avatar
    9 posts
    Member since:
    Sep 2010

    Posted 24 Sep 2010 Link to this post

    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.
  3. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 27 Sep 2010 Link to this post

    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
  4. Ivan
    Ivan avatar
    9 posts
    Member since:
    Sep 2010

    Posted 27 Sep 2010 Link to this post

    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.

Back to Top