is not using the current radeditor but it is using the 1 version back of the radeditor.
The problem is once a letter has been generated, extra html is placed in the letter that is generated causing
unexepcted blank lines to appear.
The template (letter) before the letter is displayed is stored in a sql server 2016 database in a column is is called
'stringtemplate' and is setup as a varchar(max), null) column in the database. I edit the template values directly using sql
server management studio.
Here are 2 examples of problems that I am having:
1. In one template where the value is setup as
'<br/><br/>' the values end up being '<p></p<p></p><p></p>' when the letter is actually generated.
2. in another template where the value is setup as:
<span style="font-size: 13px;font-family: arial,sans-serif; color: black;"><br />
with the final </span> and the end of the template
the letter that is generated actually has the following html:
<span style="color: black; font-family: arial,sans-serif; font-size: 13px;"><br />
<span style="color: black; font-family: arial,sans-serif; font-size: 13px;">
with the final </span> and the end of the letter.
Thus would you tell me and/or show me what I can do to solve the problem?
7 Answers, 1 is accepted
Could you confirm that both HTML snippets are valid HTML before being given to RadEditor? This is important to ensure proper functionality. If the HTML string is invalid, the browser may change it unexpectedly and also RadEditor's ConvertToXhtml filter will also attempt to fix it.
What I can suggest that you test is the following demo: https://demos.telerik.com/aspnet-ajax/editor/examples/builtincontentfilters/defaultcs.aspx. You can paste the original HTML strings you have in the HTML mode of the editor, flip to Design and back to HTML to see how the content changes depending on the various filter combinations.
You can also run this project locally so you can change the NewLineMode property of the control to Br to see if this provides results closer to your preference. Note that doing so will deteriorate the end user experience pertaining mostly to working with lists crating paragraphs of text and their alignment.
On the second snippet - this behavior is expected because a paragraph (a block element) cannot be nested in a span (an inline element). Disabling the ConvertToXhtml filter should help you avoid this change, but it can also cause other issues like increased chance of invalid HTML and other combinations that may not be well understood by an HTML parser.
On a side note - if you only want to generate emails from that HTML, and not have end users edit them, perhaps you do not need a RadEditor at all, and string operations on the server can let you do that generation.
Thank you for your response!
I have the following additional items to mention to you:
1. I have users that have said within the last 6 months after the latest Telerik tool has been installed, that more extra blank lines have been generated. They have to remove all these extra blank lines when the start to work with these generic letters (templates). The sql in the database has not changed. I am going to watch this situation, but I don't think this is possible, corect? If this is possible, can you tell me how this occurs and what I can do to solve the problem?
2. You had a side note about generating email messages. In this application, the user edits letters. That is why the application uses the radedior.
I was not sure what the setup you had is, so I had to mention that. It seems you will be needing the editor.
There haven't been recent changes in the control and such an upgrade is not expected to cause more or less whitespace. In my personal experience, users often add empty paragraphs while trying to space out something, they tend to do that in MS Word as well. Could you check whether this is the user behavior or the editor that adds the empty paragraphs?
Also, what happens if you set the NewLineMode to Br (I'd do that with a subset of users who you can talk to, if possible, because it will cause some issues with the control behavior, see here for more details)?
I would also suggest you play around with the filters the control offers to see if something there is causing this (e.g., ConvertToXhtml may be trying to fix some malformed content).
1. The users say they are not adding the extra sapces. Due to that fact, would you tell me how the editor can be adding extra paragraphs? Would you show me how to make the editor not add the extra paragraphs?
2. Would you tell me where I can set the NewLineMode to Br ? What is the default value for the NewLineMode when upgrading to a newer version of the Telerik tool?
I am assuming this is added to the web.config file by default or somewhere else? I am using whatever the defaults are set for the Telerik controls whenever I upgrade to a new version of the Telerik tool.
The editor does not have a setting that instructs it to add or not to add empty paragraphs. Generally, this should not happen, and the only case I've seen similar behavior is when the initial HTML passed to it is invalid XHTML. With this in mind, to help further I will need to be able to reproduce this problem in order to debug it.
On NewLineMode - this is a property on the control tag and it defaults to P (as in paragraph). So, you set it like this:
The P is the default value since Q2 2014, before that it was Br.
If you need to get back to this, please also post an MCVE so we can investigate.