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

[Solved] strip out html?

4 Answers 161 Views
RadEditor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
cdutson
Top achievements
Rank 1
cdutson asked on 30 Aug 2006, 03:30 PM
is there any way to strip out the html that the user dumps in on save or something?

eg.

<b>hello</b><br/> this is a test.

would become "hello this is a test." or "hello\n this is a test".

Im sure I could third-party it (use some insane regex in a javascript/c# replace), but I am sort of hoping it is in some hidden nook of the RAD Editor, or if someone has already done this.

Thanks a bunch!

4 Answers, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 31 Aug 2006, 02:45 PM
Hello Corey,

The editor offers both a server and a client side ability to get its content as plain text. On the server you can just use the editor.Text property. It will supply you with the plain text representation of the content. On the client you can use the GetText() method, which again returns plain text.

You can read more about the editor server/client API in the online documentation at http://www.telerik.com/support/documentation/r.a.d.editor.aspx

Sincerely yours,
Lini
the telerik team
0
Kartik Ganesan
Top achievements
Rank 1
answered on 28 Sep 2007, 03:30 PM
Hi,

Is there a way by which we can selectively filter the HTML.

Meaning, In our application in one of the screens we want to strip all the html except <br/> and also retain the new lines for the bullets.

Server side functionality for doing this would be good as we need to display this in RadGrid.

Thanks

Kartik
0
Lini
Telerik team
answered on 03 Oct 2007, 11:59 AM
Hello,

The MOSSRadEditor control has a property Text, which returns only the text value of the editor. You can use it to strip all HTML from the editor content. If you want to preserve the <br/> tags, simply replace them with something else before you use the Text property. For example:

Editor1.Content = Editor1.Content.Replace("<br/>""%EDITORBREAK%");  
String textContent = Editor1.Text;  
textContent = textContent.Replace("%EDITORBREAK%""<br/>"); 

Greetings,
Lini
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kartik Ganesan
Top achievements
Rank 1
answered on 03 Oct 2007, 01:06 PM
Great.

Thanks

KG
Tags
RadEditor
Asked by
cdutson
Top achievements
Rank 1
Answers by
Lini
Telerik team
Kartik Ganesan
Top achievements
Rank 1
Share this question
or