FindControl inside Editor

6 posts, 1 answers
  1. Michael
    Michael avatar
    18 posts
    Member since:
    Jun 2009

    Posted 14 Dec 2009 Link to this post

    I have the following code below. In my codebehind I am trying to find the div 'EditBody1' through the findControl method, but the page never recognizes it. Does anyone have any suggestions in order to find the div?

    <

     

    telerik:RadEditor runat="server" ID="RadEditor1" >

     

     

    <Content>

     

     

    <asp:Button ID="btnSubmit2" runat="server" Text="Submit"/>

     

     

    <table>

     

     

    <tr>

     

     

    <td><div id="EditBody1" runat="server" contentEditable="true" unselectable="off">My content area 1</div></td>

     

     

    </tr>

     

    </table>

     

     

    </Content>

     

     

    </telerik:RadEditor>

    Thank you

    Mike

     

  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 14 Dec 2009 Link to this post

    Hi Michael,

    RadEditor is web-based WYSIWYG editor that works and outputs HTML content only - it is not an iNaming container and cannot be used as such. You can access the DIV on the client only by using editor.get_document().body.getElementByID("EditBody1 ");



    Sincerely yours,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michael
    Michael avatar
    18 posts
    Member since:
    Jun 2009

    Posted 14 Dec 2009 Link to this post

    Thank you for your reply.

    When I use the following code I keep receiving an error saying "Object doesnt support this property or method".

    <

     

    telerik:RadEditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad">

     

    <

     

    Content>

     

     

    <table>

     

     

    <tr>

     

     

    <td><div id="EditBody1" runat="server" contentEditable="true" unselectable="off">My content area 1</div></td>

     

     

    </tr>

     

    </table>

     

     

    </Content>

     

     

    </telerik:RadEditor>

     


    function

     

    OnClientLoad(editor, args) {

     

        alert(

    "EditBody1: " + editor.get_document().body.getElementByID("EditBody1 "));

     

    }

    Is there anything else I need to add?

  5. Answer
    Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 14 Dec 2009 Link to this post

    Hello Michael,

     Would you please try replacing getElementByID with getElementById and test again? JavaScript is case sensitive and thus getElementByID and getElementById are different things for it and the method which actual name is without capital "D" is not found.


    Greetings,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Michael
    Michael avatar
    18 posts
    Member since:
    Jun 2009

    Posted 14 Dec 2009 Link to this post

    I have made the change to the code below, but I am still receiving the same error.

    editor.get_document().body.getElementById(

    "EditBody1")

    I also tried the following as well but it did not work.

     

    editor.get_document().body.getElementById(

    "EditBody1").innerHTML

     

  7. Michael
    Michael avatar
    18 posts
    Member since:
    Jun 2009

    Posted 14 Dec 2009 Link to this post

    After some fiddling around I managed to get it to work with the code below.

    editor.get_document().getElementById(

    "EditBody1").innerHTML

     

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