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

Open RadWindow with dynamic content using javascript

2 Answers 411 Views
Window
This is a migrated thread and some comments may be shown as answers.
Raymond
Top achievements
Rank 1
Raymond asked on 24 May 2014, 04:51 AM
Dear Sirs,

I would like to open a radwindow using dynamic content using javascript, so no url need to specify.  For example, in javascript I can do something like:

var win = window.open('');
win.document.write('Test'); // so the window will contain the text "Test"

How can I have similar result for using radwindow without creating a temp webpage?  I would like something like:
var win = window.radopen(null, null);
win.document.write('Test'); // <-- This doesn't work

Thanks.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 May 2014, 09:27 AM
Hi Raymond,

Please try the following JavaScript to open a RadWindow with dynamic content.

JavaScript:
var oWnd = window.radopen(null, null);
oWnd._contentCell.innerHTML = "<input type='button' value='submit'></input><br/><h1>Hello World!</h1><p>Have a nice day!</p>";

Thanks,
Shinu.
1
Marin Bratanov
Telerik team
answered on 26 May 2014, 10:59 AM

Hi guys,

I advise that you use the public API of the control: http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html. It offers the set_contentElement() method. Note that the ContentTemplate is designed as a container for server controls, so you would need to declare and use a RadWindow with a ContenTemplate (even blank) for this to work as expected. The ContentTemplate element is not created upon client-side setting at this point, so having a content that is not where it is supposed to be may break the control afterwards (e.g., if autosizing is used). More details are available here: http://feedback.telerik.com/Project/108/Feedback/Details/129174.

The code posted by Shinu would work with the Classic RenderMode, but would throw an error with the Lightweight mode, because there are no more tables used.

Of course, a third option is to point the RadWIndow to a page like blank.html where you can use the same approach to write manually to the document. This article explains how to call a function in the page loaded in the RadWindow so you can write to the document: http://www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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