Setting default text via Javascript

2 posts, 0 answers
  1. Tom.S
    Tom.S avatar
    17 posts
    Member since:
    Apr 2007

    Posted 10 Dec 2008 Link to this post

     I'm looking to add some text/html to a rad editor on page load.

    The Rad Editor is being used on a NewForm.aspx page as a replacement for the default rich text editor. As the control is being added dynamically, i can't obtain a reference using the control name:

    var editor = $find("<%=RadEditor1.ClientID%>"); 

    So my approach is to traverse over the DOM and find the ID of the RAD editor control. I can do this successfully using the below javascript:


    <script type="text/javascript">  
    function fillDefaultValues() {  
     var oJobBrief = getTagFromIdentifierAndTitle("textarea""TextField""Job Brief");  
     var temp1 = oJobBrief.parentNode.previousSibling;   
     var oRadEditor = $find(;  
     oRadEditor._contentArea.innerHTML = "test";  
        function getTagFromIdentifierAndTitle(tagName, identifier, title) {  
          var len = identifier.length;  
          var tags = document.getElementsByTagName(tagName);  
          for (var i=0; i < tags.length; i++) {  
            var tempString = tags[i].id;  
            if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {  
              return tags[i];  
          return null;  

    Using the $find function on Firefox returns a reference to the Rad editor instance. However I get nothing back when doing this from IE.

    Can you help? Is there an easier way to set text in the rad editor for a specific page?

  2. Stanimir
    Stanimir avatar
    1654 posts

    Posted 12 Dec 2008 Link to this post

    Hi Tom.S,

    In our online Knowledge Base you can find an article called How to execute custom code called on RadEditor's events.

    I think that you might find this helpful.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top