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

javascript help

2 Answers 32 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 14 Sep 2011, 04:32 PM
Hi,

I'm basing my question off of the example here:
http://www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html

The example has this nice and simple javascript function:

function CallFn()
{
  var oWnd = GetRadWindowManager().getWindowByName("RadWindow1");
  oWnd.get_contentFrame().contentWindow.CalledFn();
}   


What I would like is to make the function that gets called a parameter like this (which of course won't work, but that's where you geniuses come in!)

function CallFn(WindowName,FunctionName)
{
  var oWnd = GetRadWindowManager().getWindowByName(WindowName);
  oWnd.get_contentFrame().contentWindow.FunctionName
}   

Help!
Thank you!

2 Answers, 1 is accepted

Sort by
0
Sam
Top achievements
Rank 1
answered on 14 Sep 2011, 07:05 PM
I have something working that is server side and client side, but I would like to know how to do this right with just javascript.

Here is what I have in vb:
Public Shared CallFunctionOnCallingWindowString As String = ""
Public Sub CallFunctionOnParentPage(ByVal CallingWindowPageName As String, ByVal FunctionName As String, ByVal CloseThisWindow As Boolean)
    Dim s As String = ""
    If CloseThisWindow = True Then
        s = "CloseThisWindow();"
    End If
    Me.CallFunctionOnCallingWindowString = "CallingWindowContent." & FunctionName
    Me.RadAjaxManagerMain.ResponseScripts.Add("CallFunctionOnCallingWindow('" & CallingWindowPageName & "');")
End Sub

and this is the client side js:
function CallFunctionOnCallingWindow(CallingWindowPageName) {
    var oWindow = GetRadWindow();
    var CallingWindow = oWnd.get_windowManager().getWindowByName(CallingWindowPageName);
    var CallingWindowContent = CallingWindow.get_contentFrame().contentWindow;
    <%= Me.CallFunctionOnCallingWindowString %>
}
0
Accepted
Marin Bratanov
Telerik team
answered on 15 Sep 2011, 11:58 AM
Hello Sam,

Please examine the following thread which discusses the same issue: http://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string.

For your convenience I have attached a simple page that achieves this behavior.


Regards,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
Window
Asked by
Sam
Top achievements
Rank 1
Answers by
Sam
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or