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

[Solved] Repair Html

3 Answers 139 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Wolfgang Höfler
Top achievements
Rank 1
Wolfgang Höfler asked on 22 Oct 2009, 09:05 AM
Hi,

i have recognized, that the RadEditor has an powerful HtmlRepair function.
If i set the content of the editor:
<div><li>test<li>test2</li></div
 

it produces an output like this
<div> 
<li>test</li> 
<li>test2</li> 
</div> 
 

Now i have the problem that i have to use this html-repair functionality without the editor.
Is this possible?

Thanks in advance!


3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 27 Oct 2009, 10:42 AM
Hello Wolfgang,

It is the ConvertToXhtml built-in content filter of RadEditor that validates the content. This filter however is part of the RadEditor code and it cannot be used without the editor. What you can do is to place the editor in a hidden div and obtain the content through this filter via the editor.get_html(true) method, e.g.

<div style="display:none;">
    <telerik:RadEditor runat="server" ID="RadEditor1"></telerik:RadEditor>
</div> 
<input type="button" onclick="SetContent();return false;" value="Set Content" />
<input type="button" onclick="GetContent();return false;" value="Get Content" />
<script type="text/javascript">
    function SetContent()
    {
        var editor = $find("RadEditor1");
        var content = "<div><li>test<li>test2</li></div>"
        alert("Content to be set in RadEditor: " + content);
        editor.set_html(content);
    }
    function GetContent()
    {
        var editor = $find("RadEditor1");
        alert("Validated by RadEditor content:\n " + editor.get_html(true));
    }
</script>

Please, note that this solution is not supported by Telerik.

Sincerely,
Rumen
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
Wolfgang Höfler
Top achievements
Rank 1
answered on 28 Oct 2009, 07:14 AM
Thank you for the answer,

but we need this functionality in an non-Browser-environment, without Javascript. Is this possible?

Thanks in advance.
0
Rumen
Telerik team
answered on 28 Oct 2009, 07:35 AM
Hi Wolfgang,

RadEditor is an ASP.NET AJAX web editor and it cannot be used in non web environment.
For validating HTML content in a non - browser - environment I suggest using the Tidy tool. It is designed to fix mistakes in HTML, tidy up the layout (hence the name), assist with web accessibility, convert HTML to XHTML and many other things.

You can download it from the following site:

http://www.paehl.com/open_source/?HTML_Tidy_for_Windows

More information can be found in the W3C site:
http://www.w3.org/Status.html


Best wishes,
Rumen
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
Wolfgang Höfler
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Wolfgang Höfler
Top achievements
Rank 1
Share this question
or