Open RadWindow with dynamic content using javascript

3 posts, 0 answers
  1. Raymond
    Raymond avatar
    1 posts
    Member since:
    May 2014

    Posted 23 May 2014 Link to this post

    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 ='');
    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

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 May 2014 in reply to Raymond Link to this post

    Hi Raymond,

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

    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>";

  3. Marin Bratanov
    Marin Bratanov avatar
    3907 posts

    Posted 26 May 2014 Link to this post

    Hi guys,

    I advise that you use the public API of the control: 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:

    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:


    Marin Bratanov

    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.

Back to Top