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

How do I clear the content of the RadEditor

4 Answers 153 Views
Editor
This is a migrated thread and some comments may be shown as answers.
adec
Top achievements
Rank 1
adec asked on 18 Jan 2009, 11:44 AM
I have encountered a little problem  when the Editor is not in an UpdatePanel control and the Button which saves the content is. The content of the Editor simply will not be cleared during the Button OnClick event. I have tried several client-side approaches, so far without success. I'm sure this is very simple, so if someone could point me in the right direction it would be much appreciated.

4 Answers, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 20 Jan 2009, 07:48 AM
Hi adec,

To clean the editor content on the client-side you need to get a reference to the editor and call its set_html method, e.g.

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


Best regards,
Tervel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
adec
Top achievements
Rank 1
answered on 20 Jan 2009, 08:38 AM
Hello Tervel and thanks for your reply. I have already tried this approach and it doesn't work. I wonder if the use of a ConfirmButtonExtender has anything to do with it. As it is now, I have added OnClientClick to the Button inside the UpdatePanel control like so; 

<asp:Button ID="SaveDiaryEntry2" runat="server" Text="Spara allt permanent" OnClick="SaveDiaryEntry_Click" 

 

SkinID="MemberButton" UseSubmitBehavior="true" ValidationGroup="Entry" OnClientClick="ClearEditor" />  

 

<cc1:ConfirmButtonExtender ID="SaveDiaryEntry2_ConfirmButtonExtender" runat="server"  

 

ConfirmOnFormSubmit="True" ConfirmText="Spara din dagboksanteckning? När anteckningen sparas kan den inte längre ändras..."  

 

Enabled="True" TargetControlID="SaveDiaryEntry2">  

 

</cc1:ConfirmButtonExtender>

My ClearEditor Function is located near the top of a ContentPage:

 

<script type="text/javascript">  

 

function ClearEditor() {

 

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

 

editor.set_html(

""); 

 

}

 

</script

just after the ScriptManagerProxy. Any thoughts?

0
Tervel
Telerik team
answered on 20 Jan 2009, 08:51 AM
Hello adec,

Before we delve any further, I would suggest adding a simple alert('hello') statement before the editor reference, just to make sure your code gets properly called.


Best wishes,
Tervel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
adec
Top achievements
Rank 1
answered on 20 Jan 2009, 12:22 PM
Hello again,

I have now tried this approach and the alert never shows so the client-side function is not executed. It seems this function needs to be called when the OK button in the ConfirmButtonExtender is pressed.

 

Tags
Editor
Asked by
adec
Top achievements
Rank 1
Answers by
Tervel
Telerik team
adec
Top achievements
Rank 1
Share this question
or