I have a RadEditor and set its MaxHtmlLength to 50. When I enter more than 50 characters (without any markups) it show an alert box, which is as expected. However, if I add a list, it takes more than 50 characters and does not show an alert message.
When I tested the length of the content in server side, it is more than 50.
Here is what I did:
1. Add a RadEditor and a RadButton on the aspx page.
2. On Page_Init set the MaxHtmlLength to 50.
this.RadEditor1.MaxHtmlLength = 50;
3. Enter some text and click the button for save.
Text I used is:
one two three four five six seven eight nine tens
It has length of 49. If I add another character, I get an alert box though the MaxHtmlLength is 50.
4. Try some text in a list.
Text I used is:
The content for this is, "<ul>\r\n <li>one</li>\r\n <li>two thre</li>\r\n</ul>" and the length is 52. I don't get any alert message for this. However, if you try to add one more character, I get an alert message.
This is how I checked the content and length.
this.RadEditor1.Content.Length; // Get the length of RadEditor content (the value is 52)
this.RadEditor1.Content; // Get the content of the RadEditor ( the value is "<
If you increase the MaxHtmlLength to 70 and try with 3 list items, the maximum length allowed is 73. I tested with MaxHtmlLength of 30, 50, and 70 for which the lengths allowed without any alert message are 31, 52, and 73 respectively.
Note: All this was done using google chrome.
The behavior is different in IE 8. It allows for more than the specified MaxHtmlLength and also appends space at the end of each list.
Here is how you can reproduce the problem
1. Add the text in list ( I used the same text)
Save the data. (For this I have changed the maximum length for the field to 55 in database). It saves without any alert message.
Now, initialize the editor content with the data and try to save again. The same data is not allowed to save and an alert message pops up. I checked and found that space is appended at the end of each list.
Here is the content in IE8
"<ul>\r\n <li>one </li>\r\n <li>two thre </li>\r\n</ul>"
See the space between the 'e' in one and </li> and also between 'e' in thre and </li> and the length is 54. Try removing 'hr' ( any two characters) it allows to save with the length of 52. It is supposed to show an alert message.
Here is the code for get and set.
this.RadEditor1.Content = value;
I hope this helps you to reproduce the issue.