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

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

2 Answers 74 Views
Window
This is a migrated thread and some comments may be shown as answers.
ian webster
Top achievements
Rank 1
ian webster asked on 16 Oct 2009, 07:39 AM
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 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 21 Oct 2009, 11:24 AM
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.
0
ian webster
Top achievements
Rank 1
answered on 22 Oct 2009, 03:52 PM
Thanks Georgi your suggestion worked.
Tags
Window
Asked by
ian webster
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
ian webster
Top achievements
Rank 1
Share this question
or