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

[Solved] OnClientSubmit replace text

2 Answers 114 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Connections Academy Developer
Top achievements
Rank 1
Connections Academy Developer asked on 16 Oct 2009, 01:27 PM
I am trying to replace <noscript> tags with [noscript] in the OnClientSubmit function but when I click the submit button nothing happens. Can you tell me what I'm doing wrong?

function OnClientSubmit(editor, args) {
     var content = editor.GetText();
    
     if (content) {
     newContent = content.replace('<noscript>', '[noscript]');
     newContent = content.replace('</noscript>', '[/noscript]');
     }
     <%=textEditor.ClientID%>.Submit();
     return false;
    }

2 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 19 Oct 2009, 08:20 PM
I would recommend taking another look at the client-side API. You are using GetText() when the method is described as get_text(). And you might also want to take a look at using get_html and set_html. Hopefully this will help.
0
Lini
Telerik team
answered on 21 Oct 2009, 12:27 PM
Hello,

The GetText() method was part of the classic ASP.NET RadEditor client API so I assume that the question is for that control and not the ASP.NET AJAX version. You need to use the GetHtml() and SetHtml() methods of the editor object to update its content:

...
var content = editor.GetHtml();
    
     if (content) {
     var newContent = content.replace('<noscript>', '[noscript]');
     newContent = newContent.replace('</noscript>', '[/noscript]');
                editor.SetHtml(newContent);
     }
...

Kind regards,
Lini
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.
Tags
Editor
Asked by
Connections Academy Developer
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Lini
Telerik team
Share this question
or