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

calling a javascript function in a radwindow

3 Answers 263 Views
Window
This is a migrated thread and some comments may be shown as answers.
Matthew Bishop
Top achievements
Rank 1
Matthew Bishop asked on 05 Dec 2007, 01:40 AM
Im trying to call a javascript function on the page created by RadWindowManager. To do this without the RadWindowManager you would do something like this:
'iframe1.helloworld();' or eval("iframe1.helloworld();");
from the parent page.

However, I cannot manage to do this using RadWindowManager.

Any suggestions on how I can do this?

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 05 Dec 2007, 01:49 PM
Hi Matthew,

Here is how to call a Javascript function in a RadWindow from the parent page (code taken from the control's documentation, section RadWindow Client-Side): 

//Call a predefined function in opened RadWindow  
function CallFn()  
{  
   var oWnd = $find("<%=RadWindowManager1.ClientID %>").getWindowByName("RadWindow1");  
   oWnd.get_ContentFrame().contentWindow.CalledFn(); //CalledFn() must exists in the RadWindow's content  


I hope this helps.


Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Matthew Bishop
Top achievements
Rank 1
answered on 06 Dec 2007, 01:37 AM
It certainly did, thanks. One thing I noticed though is that when I pass variables to the function, it will only accept one variable.
eg:
From main page
oWnd.get_ContentFrame().contentWindow.CalledFn('This is X','This is Y'); 

From target page
function CalledFn(x,y)
{
    alert(x,y);
}

Will only alert 'This is X'.
Whilst it is no problem since I just call back to the main page to get the variables, yet another function does get messy.

Is this a bug with the control?

0
Georgi Tunev
Telerik team
answered on 06 Dec 2007, 07:53 AM
Hi Matthew,

The arguments are passed correctly, however you cannot alert them like that - you can try this for yourself by testing the following example - the result will be the same.

<script type="text/javascript">
function calledFn(x,y)
{
    alert(x,y);
}
</script>
<button onclick="calledFn('one','two'); return false;">test</button>

More information on the comma operator can be found in varuous places in the Net - for example here:
http://www.webreference.com/javascript/reference/core_ref/ops.html


Try with alert(x + y) or alert(x + "  " + y) - this way you can alert both arguments.




Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Window
Asked by
Matthew Bishop
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Matthew Bishop
Top achievements
Rank 1
Share this question
or