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

Getting issue in disable auto correction of html elements

1 Answer 114 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Aminul
Top achievements
Rank 1
Aminul asked on 17 Dec 2014, 01:38 PM
Hello Expert,

I am getting an issue in disable auto correction of html element. 
I have a RadEditor where I want to get and set any none valid/formatted html element as like "<noclick> Somethings".
I tried to do this, my code taking none valid/formatted html element as like "<div>Hello World" and giving this same value in server side and I can save this value in database. Then I retrieve this html element from database and bid this html element to RadEditor.Content. But when I browse this page; I can see this value are showing as  <div>Hello World</div> in RadEditor . That's mean its adding end tag to correct html format. But I don't need to add this end tag in my html elements.

Here is my code:

<telerik:RadEditor ID="txtTextScript" runat="server" Font-Size="Larger" EditModes="Html" ContentAreaMode="Div" ContentFilters="None" Height="100" Width="349px">
     <Tools>
              <telerik:EditorToolGroup >
              </telerik:EditorToolGroup>
      </Tools>
</telerik:RadEditor> 

protected void Page_Load(object sender, EventArgs e){
        txtTextScript.DisableFilter(Telerik.Web.UI.EditorFilters.ConvertToXhtml);
}
 
I tried by following this link but still not working
http://www.telerik.com/forums/how-to-disable-auto-correction-of-html-elements?actionMode=replyThread


I am waiting for a quick response from someone.

Thanks
Aminul

 








1 Answer, 1 is accepted

Sort by
0
Niko
Telerik team
answered on 22 Dec 2014, 09:53 AM
Hello Aminul,

The Editor control from the Telerik UI for ASP.NET AJAX relies on the editable content capabilities of browsers. In that respect all content is rendered on the page and thus translated as HTML. This forces the browser parsing and rendering machines to evaluate the content and try to fix any missing HTML content.

You will get the same result if you try to add invalid HTML to an existing DOM element:
$get("content").innerHTML = "<div>content";

On the other hand, if you wish the content in the Design mode to appear as "<div>content", then you should encode it on the server:
theEditor.Content = HttpUtility.HtmlEncode(content);

Hope this helps.

Regards,
Niko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Editor
Asked by
Aminul
Top achievements
Rank 1
Answers by
Niko
Telerik team
Share this question
or