Old code from 2008 Q3 1314 not working in 2009 Q2 826

3 posts, 0 answers
  1. ian webster
    ian webster avatar
    14 posts
    Member since:
    Jan 2006

    Posted 16 Oct 2009 Link to this post

    Hi,

    I've encountered a problem after upgrading from RadControls for ASP.Net AJAX 2008 Q3 1314 to 2009 Q2 826.

    I'm using rad windows and when the user closes one they get a warning in a rad confirm box, if they click ok the window should close if they click cancel it stays.

    This all worked great in the 2008 Q3 release but in the newer 2009 Q2 release when you click ok on the rad confirm box the window doesn't close.

    Here are the scripts I am using to open the windows and to handle the showing on the confirm box:

        function OpenAWindow(url, title) {  
            var win = radopen(url, null);  
            win.set_title(title);         
            win.set_status("");  
            win.add_pageLoad(function() { win.set_status(""); });  
            alert(win.offsetLeft);  
        }  
          
        function OnBeforeClose(sender, arg) {  
            function callbackFunction(arg) {  
                if (arg) {  
                    sender.remove_beforeClose(OnBeforeClose);  
                    sender.close();  
                    if (!AnyWindowsVisible()) {  
                        document.getElementById('<%= btnClose.ClientID %>').click();  
                    }  
                }  
            }  
            arg.set_cancel(true);  
            var messageBody = document.getElementById('<%= hdnWarningMessage.ClientID %>').value;  
            var messageTitle = document.getElementById('<%= hdnWarningTitle.ClientID %>').value;  
            radconfirm(messageBody, callbackFunction, 300, 100, null, messageTitle);  
        }  
     
        function AnyWindowsVisible() {  
            var result = false;  
            var manager = GetRadWindowManager();  
            for (var i = 0; i < manager.get_windows().length; i++) {  
                if (manager.get_windows()[i].isVisible()) {  
                    result = true;  
                    break;  
                }  
            }  
            return result;  
        }  
     
        function OnClientShow(sender) {  
            sender.add_beforeClose(OnBeforeClose);  
        } 
    and the html:

    <asp:UpdatePanel ID="pnlScript" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">  
        <ContentTemplate> 
            <asp:Literal ID="litScriptAnchor" runat="server" /> 
            <asp:HiddenField ID="hdnWarningMessage" runat="server" /> 
            <asp:HiddenField ID="hdnWarningTitle" runat="server" /> 
        </ContentTemplate> 
    </asp:UpdatePanel> 
    <div class="TelerikWindowRestrictedZone_Container">  
        <div class="TelerikWindowRestrictedZone_Header">  
        </div> 
        <div id="WindowContainer" class="TelerikWindowRestrictedZone_Body">  
        </div> 
    </div> 
    <asp:UpdatePanel ID="pnlWindowCommands" runat="server">  
        <ContentTemplate> 
            <asp:Button ID="btnClose" runat="server" Text="close" OnClick="btnClose_Click" Style="display: none;" /> 
        </ContentTemplate> 
    </asp:UpdatePanel> 
    <asp:UpdatePanel ID="pnlWindows" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">  
        <ContentTemplate> 
            <telerik:RadWindowManager ID="ucRadWindowManager" RestrictionZoneID="WindowContainer" OnClientDragEnd="FixFocus" OnClientResize="FixFocus" OnClientCommand="FixFocus" OnClientShow="OnClientShow" PreserveClientState="true" runat="server" Skin="Telerik">  
            </telerik:RadWindowManager> 
        </ContentTemplate> 
    </asp:UpdatePanel> 

    any ideas?

    Thanks,

    Ian
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 21 Oct 2009 Link to this post

    Hello Ian,

    With the recent versions of the control, OnClientShow, OnClientClose etc. are called for the dialogs (radprompt, radconfirm, radalert) as well. That is the reason why your code is not working as expected. I suggest to set the OnBeforeClose handler directly to the RadWindow object when you open it, e.g.
    win.add_beforeClose(OnBeforeClose);
    otherwise it will be added to the radconfirm dialog as well.



    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. ian webster
    ian webster avatar
    14 posts
    Member since:
    Jan 2006

    Posted 22 Oct 2009 Link to this post

    Thanks Georgi your suggestion worked.
Back to Top