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

Calling a Javascript function from a RadWindow that is another RadWindow

2 Answers 432 Views
Window
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 13 Jul 2016, 07:43 PM

I know this has come up multiple times and I have read multiple posts but have not been able to get it to work

On the parent page in the web browser, there is a button.  When a user clicks on the button, it opens a page with a RadGrid in a RadWindow.  We will call that WindowA.

In the RadGrid in WindowA, each record has a column with a HyperLink.  When clicking on the HyperLink, it opens a different page in another RadWindow for the user to edit and update the data for that record. We will call that WindowB.

When the user edits the data and clicks on the Update button in WindowB, it needs to do the following:

- Execute a SQL statement to update the record in the database table.

- Close WindowB.

- Refresh or Rebind the RadGrid in WindowA using the RadAjaxManager to call an ajaxRequest to show the changes in the data.

-----------------------------------------------------------------------

I was able to do something similiar between the browser window (parent) and a RadWindow where the parent has the RadGrid which gets updated after user clicks on Update button in RadWindow.  But I cannot get the scenario above to work.

-----------------------------------------------------------------------

I have read the article in http://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/calling-functions-in-windows .

When I debug through the Javascript function, I get the error " Object doesn't support property or method 'get_ContentFrame' " on the following line of code:

oWnd.get_ContentFrame().contentWindow.MyTestViewTodayRelFn();

Below is my code.

Please help me to get this to work.  A working example would help alot.

Thanks!

------------------------------------------------------------------------

Update button click subroutine in code-behind for page in WindowB ( VB code)

Protected Sub rbtnUpdateOrder_Click(sender As Object, e As EventArgs) Handles rbtnUpdateOrder.Click

...

ScriptManager.RegisterStartupScript(Me, [GetType](), "mykey", "CloseAndRebind();", True)

...

End Sub

Javascript function CloseAndRebind in page in WindowB (put in <head> </head> section):

        function CloseAndRebind(args) {

            var oManager = GetRadWindow().BrowserWindow.GetRadWindowManager();
            var oWnd = oManager.getWindowByName("Release History");
            oWnd.get_ContentFrame().contentWindow.MyTestViewTodayRelFn();

            alert(oWnd);
            GetRadWindow().close();
        }

Javascript function MyTestViewTodayRelFn in page in WindowA (put in <head> </head> section):

        function MyTestViewTodayRelFn() {
            alert("Called MyTestViewTodayRelFn");
        }

Note: MyTestViewTodayRelFn is just a test function.  Here is an example of what the actual function would be in the page for WindowA:

            function refreshGridRYG(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                }
            }

Sincerely,

Keith Jackson

2 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 14 Jul 2016, 11:02 AM

Hi Keith,

I advise you start from the following code library project that the help article links: http://www.telerik.com/support/code-library/creating-parent-child-relationships-between-radwindows-and-passing-data-between-them. It uses the close event of WindowB to execute logic in WindowA.

Also, the correct method name is get_contentFrame, not get_ContentFrame, as listed in the article you linked and in the RadWindow API: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/client-side-programming/radwindow-object.

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Keith
Top achievements
Rank 1
answered on 14 Jul 2016, 12:39 PM

Thanks Marin!

I actually got the following line of code from an old post in the Telerik forum:

oWnd.get_ContentFrame().contentWindow.MyTestViewTodayRelFn();

Just the function name at the end was different. I did not realize that "get_ContentFrame()" was incorrect.  When I changed "get_ContentFrame()" to "get_contentFrame()", it worked.

Thanks for your help!

Sincerely,

Keith Jackson

Tags
Window
Asked by
Keith
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Keith
Top achievements
Rank 1
Share this question
or