javascript help

3 posts, 1 answers
  1. Sam Tran
    Sam Tran avatar
    85 posts
    Member since:
    Nov 2006

    Posted 14 Sep 2011 Link to this post

    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. Sam Tran
    Sam Tran avatar
    85 posts
    Member since:
    Nov 2006

    Posted 14 Sep 2011 Link to this post

    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 %>
    }
  3. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    4614 posts

    Posted 15 Sep 2011 Link to this post

    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
Back to Top