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

RadEditor not saving XHTML

5 Answers 79 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 14 May 2013, 10:19 AM
Hi - I have taken over the development and maintenance of an AspDotNetStoreFront website which utilises the Telerik RadEditor and have encountered an issue when updating a topic.

This issue is based around the auto completion of valid XHTML and it being saved to the database.  I have researched various posts and information but cannot find any specific information which matches my problem.

the problem:

The client highlighted me to a page where the layout of the front end of the site was displaying incorrectly, and so viewing the code within the page I could see INVALID HTML <div> elements.  Navigating to the admin area where the page information was stored, I could see the code within the RadEditor (HTML mode) and copied and pasted the code - running through it I could see that all opening <div> elements had their corresponding closing </div> elements.

having run a few tests, I can confirm the following:

opening an empty radeditor page, and typing within the HTML mode:

<div>

clicking update, this refreshes the page and updates the database - the RadEditor now displays <div></div> within the HTML mode window.

Checking the database - the value inserted is only <div> !!!

if I simply update the RadEditor again without changing anything, this then injects the full <div></div> as this is the value being passed from the editor to the SQL update statement.

So, if a customer accidentally inserts some invalid HTML, this will break their layout, but then viewing the code in the RadEditor, it has been corrected to be valid - but this is NOT what is stored in the database.  Double updating could be a solution, but the client is NOT happy with this in any way (as small an action as it is - he doesnt not feel it is acceptable).

PLEASE can you help to diagnose what this is doing and why.
in an ideal world I would like to turn off the auto XHTML (something I believe is not possible based on previous forum requests from others) - or at least fix the problem so it sorts out the XHTML BEFORE it submits to the database, therefore saving the correct HTML code.

Your help is very much appreciated.

5 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 17 May 2013, 10:35 AM
Hello,

I have researched the problem and found out that the browser adds the closing div tags. I reproduced this behavior even using a simple editable Iframe. Here is the video which shows the test.

I have also tested this with the RadEditor. I set a div element in HTML mode, submitted the content and the closing div was added to the content. You can see it in this video.

If this is not the case, could you open a support ticket and provide a sample project that shows this behavior and the content that you have been testing with for further investigations?

Best regards,
Nikolay
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jonathan
Top achievements
Rank 1
answered on 17 May 2013, 11:23 AM
Hi Nikolay

Unfortunately I cannot supply a sample project as this is part of a much larger project and it would be difficult for me to split it all down.
I am however happy to share my screen with you in a join.me session so you can see what is happening - also conferring over skype if possible.

essentially, if I enter <div> into the editor, and then print the results that are posted - I get just the <div> (no closing tag).  as the page refreshes upon submit - the radeditor then shows <div></div>.  naturally if I post this a second time, it then includes the closing tag.

simply using Response.Write(radDescription.Content)  on the submission prints out only the one <div>


Thanks
0
Nikolay
Telerik team
answered on 22 May 2013, 11:00 AM
Hi,

If I understand you correctly you want the unclosed div tag to stay unclosed. This is, however, invalid HTML while the purpose of the RadEditor control is to provide valid XHTML content. There are a lot of content filters in the control that take care of similar problems.

Even if you disable the content filters we have the browser's rich-text editing engine will step in and add the closing </div> tag. This is a browser behavior, which we cannot influence, and what I can suggest is that you validate the content before saving it into the database. You can see on the following demo how to use ASP.NET validators with the RadEditor: Editor - ASP.NET Validators Support. You can use a custom validator and modify the content as desired or at least notify the user that the content is not desired.

Regards,
Nikolay
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jonathan
Top achievements
Rank 1
answered on 23 May 2013, 06:57 AM
Hi Nikolay,

No, ideally I WOULD like it to validate as it is meant to - the problem encountered is that it is not validating and adding the closing tags before the database update.  Based on my experience, the editor validates and adds the closing </div> only when the page refreshes after an update to the DB has been made.

can you let me know how I can show you what is happening, or would it help if I supply the code files I have (although they are part of a larger project and will not run on their own)

thanks
0
Nikolay
Telerik team
answered on 28 May 2013, 06:16 AM
Hi,

Could you confirm that the ConvertToXhtml content filter is enabled? It is enabled by default and it fixes the issue on our side. I got the RadEditor's content on the server after submit and the opened div tag contains its closing tag. It is shown in the second video from my first reply - http://screencast.com/t/z88JECD26iJ.

If ConvertToXhtml filter does not fix the problem, please isolate the issue into a sample project and sent it for further investigation. You could see how to isolate a problem into a sample project in the following blog post: Isolating a problem in a sample project. Note that we do not need any database or custom logic from the application which is not related to the issue.

Regards,
Nikolay
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Editor
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Jonathan
Top achievements
Rank 1
Share this question
or