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

set event's RadWindow with JavaScript

2 Answers 100 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alessio
Top achievements
Rank 1
Alessio asked on 10 Feb 2009, 01:17 PM
Hi,
I set the RadWindow's event to Javascript... the first time is ok, but i do a refresh with radwindow's button, my events aren't raised.

This is my code:

<body onload="OnClientPageLoad()">
function OnClientPageLoad(sender, eventArgs){                   
                var oWnd = GetRadWindow();   
                oWnd.add_pageLoad(OnClientResize);                   
                oWnd.add_resize(OnClientResize);   
                oWnd.add_command(OnClientCommand);   
                return false;   
            }   
   
            function OnClientCommand(sender, eventArgs) {                   
               alert(OnClientCommand);   
            }   
   
            function OnClientResize(sender, eventArgs) {    
               alert(OnClientResize);   
            }   
 
 

Thak.

Alessio.

2 Answers, 1 is accepted

Sort by
0
Alessio
Top achievements
Rank 1
answered on 12 Feb 2009, 09:10 AM
hi,

non came across this problem?

Thank.
Alessio.
0
Fiko
Telerik team
answered on 13 Feb 2009, 05:26 PM
Hello Alessio,

The problem occurs because you attach the same function to the RadWindow object twice. You can solve it by detaching the functions, for example, in the onunload event e.g. :

<script type="text/javascript"
    function OnClientPageLoad(sender, args) 
    { 
        var oWnd = GetRadWindow();  
        oWnd.add_resize(OnClientResize); 
        oWnd.add_command(OnClientCommand); 
    } 
    function OnClientPageUnLoad() 
    { 
        var oWnd = GetRadWindow(); 
        oWnd.remove_command(OnClientCommand); 
        oWnd.remove_resize(OnClientResize); 
    } 
    function OnClientCommand(sender, eventArgs) 
    { 
         alert(OnClientCommand); 
    } 
    function OnClientResize(sender, eventArgs) 
    { 
        alert(OnClientResize);    
    } 
    function GetRadWindow() 
    { 
        var oWindow = null
        if (window.radWindow) 
            oWindow = window.radWindow; 
        else if (window.frameElement.radWindow) 
            oWindow = window.frameElement.radWindow; 
        return oWindow; 
    } 
</script> 

I hope this helps.

Sincerely,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Window
Asked by
Alessio
Top achievements
Rank 1
Answers by
Alessio
Top achievements
Rank 1
Fiko
Telerik team
Share this question
or