Using a RadEditor inside a RadWindow as a popup

8 posts, 0 answers
  1. sarika
    sarika avatar
    6 posts
    Member since:
    Feb 2009

    Posted 25 Feb 2009 Link to this post

    Hi,
      I am using a RadWindow as a popup as mentioned in the article below.

    http://www.telerik.com/help/aspnet-ajax/window_programmingusingradwindowasadialog.html

    In this, I wanted to use a RadEditor object on the dialog page.

    The onload attribute of the <body> tag reads the argument and uses it to initialize the dialog.
    [Javascript] Initializing the dialog
    <body onload = "var currentWindow = GetRadWindow();
    var Input = document.getElementById('rdUserInput');
    Input.value
    = currentWindow.argument;">

    The rdUserInput is a RadEditor control. So, when the popup is loaded, I do not see the value displayed in the control. However, if i do an alert of Input.Value, I see the value but it is not displayed inside the control. Why is this so? Can you guide on how to get this working?

    Thank you.
  2. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 27 Feb 2009 Link to this post

    Hello sarika,

    rdUserInput is an object - but it is not  the javascript RadEditor object. In IE only (in FF your code will not enter the if at all), if no javascript object with such an ID exists, the browser tries to match an HTML element having the same ID.
    In this case there is such an object - the root html element of RadEditor.
    The correct way to get a reference to the editor is to use $find - just like you would do with any MS AJAX control, e.g.

         var editor = $find("<%=RadEditor1.ClientID%>");
    Furthermore, there is no .value property to RadEditor - and I am not sure where you read about it having such a property.
    In case you wish to set content to the editor you should use editor.set_html("Some content");

    Greetings,
    Tervel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. sarika
    sarika avatar
    6 posts
    Member since:
    Feb 2009

    Posted 27 Feb 2009 Link to this post

    Hi Tervel,
       The control that is being used inside a Telerik RadWindow is Telerik RadEditor control.
     I tried to use editor.set_html("content") as below:

    <body onload = "var currentWindow = GetRadWindow();var editor = document.getElementById('<%=rdContent.ClientID %>');editor.set_html(currentWindow.argument);">

    If I do an alert to see the ClientID I see the correct control.
    But I am getting error as the 'object does not support this property or method'.  It breaks at the point where set_html is used. Are you sure that this property exits? Or I am not using it in the right way.

    Thanks,
    Sarika
  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 02 Mar 2009 Link to this post

    Hi sarika,

    Please use the $get() function like Tervel suggested.
    document.getElementById will return the HTML of the wrapping element, not the editor object. Note that since you will be using server-side IDs in the code, you cannot put the code directly in the onload property, but you should use a separate function, wrapped in a RadCodeBlock.




    Kind regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. sarika
    sarika avatar
    6 posts
    Member since:
    Feb 2009

    Posted 10 Mar 2009 Link to this post

    Hi Georgi,
      I am new to Ajax and telerik as well. Can you please guide me on how I can use the $get() function to get the RadEditor control? Also please guide me with some sample on how to write a 'separate function, wrapped in a RadCodeBlock'.

    Thank you.
    Sarika
  7. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 12 Mar 2009 Link to this post

    Hello Sarika,

    I see that Fiko has already answered your support ticket on the same subject.


    Sincerely yours,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. maggi
    maggi avatar
    58 posts
    Member since:
    Mar 2007

    Posted 27 May 2009 Link to this post

    Hello,

       I am also getting the same error can someone help me too. i tried using var editor = $find("<%=RadEditor1.ClientID%>");  but it shows $find is not defined.

    Regards
    maggi
  9. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 May 2009 Link to this post

    Hi Maggi,

    I guess you are trying to get the client side object in onload event of page body. In ASP.NET AJAX environment, the ASP.NET AJAX controls (including RadControls for ASP.NET AJAX) are created after the page has been loaded. So we cannot access the client side object of RadControls using this approach, instead you can attach pageLoad() event in order to get the client side object. Here is the code that I tried.

    ASPX:
     
    <telerik:radeditor id="RadEditor1" runat="server" > 
        <Content> 
        </Content> 
    </telerik:radeditor> 

    JavaScript:
     
    <script type="text/javascript">    
    function pageLoad()  
    {  
        var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client-side object   
    }  
    </script> 
    Please feel free to share the comments.

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017