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

Stop editor from focing valid HTML

5 Answers 98 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Kevin Warnke
Top achievements
Rank 1
Kevin Warnke asked on 15 Mar 2010, 05:58 PM
If I edit the HTML directly in the editor and intentially leave it invalid the editor automatically completes things.  Can I turn this [usually great] feature OFF?

Thanks,
Kevin

5 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 15 Mar 2010, 07:11 PM
I believe removing the ConvertToXhtml from the ContentFilters of the RadEditor should do the trick.

I hope that helps.
0
Kevin Warnke
Top achievements
Rank 1
answered on 15 Mar 2010, 08:22 PM
Any example of how to remove that filter?  I've never done that before.

Thanks!
Kevin
0
Lini
Telerik team
answered on 16 Mar 2010, 12:47 PM
Hi Kevin,

You can disable specific filters from the code. For example:

protected void Page_Load(object sender, EventArgs e)
{
    RadEditor1.DisableFilter(EditorFilters.ConvertToXhtml);
}

Unfortunately, some of the "bad" HTML is corrected by the browser engine even before it gets to the editor filters and there is nothing you can do about it. For example, if you forget to close a <div> tag, it will be closed regardless of what filters you have enabled in the editor. Each browser has its own HTML engine but they all share the "auto-correcting" feature for invalid content.

If you need to change the content of the editor and be sure that the changes won't be reversed, the only place you can do that is on the server, before saving the editor content:

string content = RadEditor1.Content;
MakeChanges(content);
Save(content);


All the best,
Lini
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kevin Warnke
Top achievements
Rank 1
answered on 16 Mar 2010, 04:38 PM
So it sounds like what I am after is not possible then.

I want to be able to put in "<table><tr><td>" but it gets converted to an entire table definition.

I'm not sure how this is a "browser" thing given that if I were to use a textarea this would work fine.

Are you sure this is tied to the browser???  And not something the editor is causing to occur?

Thanks,
Kevin
0
Rumen
Telerik team
answered on 16 Mar 2010, 05:00 PM
Hello Kevin,

The content area of RadEditor is an editable IFRAME which uses the Rich Text Editing engine of the browser in which it operates. Every tag is a node in the DOM and it should have an opening and closing tag, in other case the content will be invalid HTML. The browser Rich Text Editing engine checks for unclosed and non well formed tags and corrects them. You can check my words by testing the attached HTML page with an editable IFRAME element in it. You will reproduce the same behavior with an editable DIV element as well as with our competitors' editors.

The content inside a textbox is just a plain text string and it is not correct to compare a standard textarea with an editable div / iframe elements, which are used to edit HTML content.

Kind regards,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Editor
Asked by
Kevin Warnke
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Kevin Warnke
Top achievements
Rank 1
Lini
Telerik team
Rumen
Telerik team
Share this question
or