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

Calling a function in RadWindow from parent window not working in IE

3 Answers 155 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sravan
Top achievements
Rank 1
Sravan asked on 14 Dec 2012, 05:39 PM
I have a main window which call the rad window and when the rad window is closed, it should call main window's call back function which is registered for add_close in the main window.Here is the code snippet
(MainWindow)
function
showNewWindow {
                // open radwindow to get new window
                var url = "/Edit.aspx";
                var oWnd = getRadWindow().BrowserWindow.GetRadWindowManager().open(url, "AddNewEditWindow");
                // subscribe to the close event for the window
                oWnd.add_close(getFieldsFromEditWindow);
            }
function getFieldsFromEditWindow()
{
  var WindowName="AddNewEditWindow";
  var targWnd = getRadWindow().BrowserWindow.GetRadWindowManager().getWindowByName(WindowName);
                var editWnd = targWnd.get_contentFrame().contentWindow;
var data_From_EditWindow=editWnd.getDetails();
}
Edit.aspx ( RadWindow)
function getDetails()
{
return "HI";
}

getDetails() function in Edit.aspx is called successfully in chrome and mozilla but in IE it is failing
when the main window is trying to call the getDetails() in call back function "getFieldsFromEditWindow()"
after the rad window is closed.
It is throwing me an error "Object doesn't support property or method 'getDetails'" 
Please help me in fixing this.




3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 17 Dec 2012, 03:31 PM
Hi Sravan,

You must attach event handlers only in the same context where the event is fired. This means that an event handler for a RadWindow should be in the page that opens the RadWindow. You can find attached a simple example of this that works fine with returning the value. I advise you examine my code and comments and employ the approach in your case.


Greetings,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Sravan
Top achievements
Rank 1
answered on 18 Dec 2012, 03:50 PM
Hi Marin Bratanov,
Thanks for your reply. I used to write the event handlers in the same way as you said.   It used to work with no errors in chrome and mozilla. But it is failing in IE as I said you in my previous post. 
FYI I tried running your code. It worked with with no errors in chrome and mozilla. But It has the same problem with IE.  I am attaching you the screen shot of error in IE. Please have a look at this. 
I m using IE 9
0
Marin Bratanov
Telerik team
answered on 19 Dec 2012, 02:22 PM
Hello Sravan,

My sample works fine on my end and the error you get means that there isn't a function with this name declared in the content page that you load inside. If the spelling is correct and there isn't a typo in your case this seems like a browser issue that it is not able to reference the function object. From what I see in the screenshot - the contentWindow property is returned, which means that you have a reference to the window object of the content page and this is where your issue originates.

What I can suggest is testing this with a simple iframe on the page instead of the RadWindow - reference it (i.e. replace targetWnd.get_contentFrame() with a document.getElementById() for your iframe) and use window.parent to call the function from the first RadWindow (you should also replace it with a simple iframe) instead of the GetRadWindow() approach. This is essentially the setup you have with the RadWindows, but simplified as much as possible - without additional markup, event handlers and eye candy. If you can get this simple setup to work, the same approach should work with the RadWindows with only a small change of references. In case simple iframes work with you, but the RadWindows do not I strongly advise that you open a formal support ticket and send us a sample project where we can investigate this.


Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Sravan
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Sravan
Top achievements
Rank 1
Share this question
or