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

add_close multiple times

2 Answers 176 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jørgen
Top achievements
Rank 1
Jørgen asked on 20 Aug 2008, 08:40 AM
Hi,

When opening my RadWindow I use add_close() to add a closing function it. However, it seems that executing add_close() multiple times (when opening the window several times) makes the closing function also execute multiple times. Is there a way to clear the closing functions?

Regards,
Sjur

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Tunev
Telerik team
answered on 20 Aug 2008, 08:45 AM
Hello Sjur,

In ASP.NET AJAX, you can use the add_eventname and remove_eventname methods to add/remove event handlers. For example:

<form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
    <script type="text/javascript"
        function openWin() 
        { 
            var oWnd = radopen("http://www.google.com", "RadWindow1");  
            oWnd.add_close(ClosingFn);  
        } 
         
        function ClosingFn(oWnd) 
        { 
            alert(oWnd + " was closed");  
        } 
         
        function removeClose() 
        { 
            var oWnd = $find("RadWindow1");  
            if(oWnd) 
            { 
                oWnd.remove_close(ClosingFn);  
            } 
            else 
            { 
                alert("RadWindow not found"); 
            } 
        } 
         
    </script> 
    <telerik:RadWindowManager  
        DestroyOnClose="true"  
        ID="RadWindowManager1"  
        runat="server"
    </telerik:RadWindowManager> 
    <button onclick="openWin(); return false;">open and set</button> 
    <br /><br /> 
    <button onclick="removeClose(); return false;">remove OnClientClose</button> 
</form> 


I hope this helps. More information on the subject is available in many ASP.NET AJAX resources on the Net - for example you can check this article:
http://dotnetslackers.com/articles/ajax/RaisingAndHandlingEventsWithASPNETAjax.aspx



Sincerely yours,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jørgen
Top achievements
Rank 1
answered on 20 Aug 2008, 09:16 AM
Thanks, I wasn't aware of that. It worked out great.

Regards,
Sjur
Tags
Window
Asked by
Jørgen
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Jørgen
Top achievements
Rank 1
Share this question
or