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

FindControl inside Editor

5 Answers 67 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 14 Dec 2009, 02:02 PM
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

 

5 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 14 Dec 2009, 02:40 PM
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.
0
Michael
Top achievements
Rank 1
answered on 14 Dec 2009, 03:08 PM
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?

0
Accepted
Svetlina Anati
Telerik team
answered on 14 Dec 2009, 03:20 PM
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.
0
Michael
Top achievements
Rank 1
answered on 14 Dec 2009, 03:27 PM
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

 

0
Michael
Top achievements
Rank 1
answered on 14 Dec 2009, 03:36 PM
After some fiddling around I managed to get it to work with the code below.

editor.get_document().getElementById(

"EditBody1").innerHTML

 

Tags
Editor
Asked by
Michael
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Michael
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or