HtmlEditorExtender losing text content after postback if there were used more lines (2+) and there are missing Justify* actions in toolbar.
Steps for reproduction:
- Open your demo application (HTMLEditorExtender.aspx)
- Remove all toolbar action excluded bold, italic and udnerline:
[CODE]
<ajaxToolkit:HtmlEditorExtender ID="htmlEditorExtender2" TargetControlID="txtBox2"
runat="server" DisplaySourceTab="True" OnImageUploadComplete="ajaxFileUpload_OnUploadComplete">
<Toolbar>
<ajaxToolkit:Bold />
<ajaxToolkit:Italic />
<ajaxToolkit:Underline />
</Toolbar>
</ajaxToolkit:HtmlEditorExtender>
[/CODE]
- Write TWO lines content ie.:
"bla bla bla
gugugu"
- Click to submit content <- as you can see, content has been cleaned.
Workaround:
Add at least one justify action:
[CODE]
<Toolbar>
<ajaxToolkit:Bold />
<ajaxToolkit:Italic />
<ajaxToolkit:Underline />
<ajaxToolkit:HorizontalSeparator />
<ajaxToolkit:JustifyLeft />
</Toolbar>
[/CODE]
Comments: This happens because of the way HtmlEditorExtender performs sanitization on the Sample Site. If you copy-paste these two lines from this site to HtmlEditorExtender and switch to the source tab, you will notice that the content is enclosed into two __span__ elements. Before the sample page performs sanitization, it calls the MakeCombinedElementList() method to create a list of elements that will be kept untouched. This method loops through the toolbar buttons and adds white elements for each button on the list. As a result, this list can lack a __span __element and it will be removed after the sanitization. This completely removes all text, providing that all sample content consists of only two __span__ elements. However, this is not a bug. You can compose a white elements list in any way you want and pass it to a Sanitizer, so that the __span__ elements will not be removed.
Steps for reproduction:
- Open your demo application (HTMLEditorExtender.aspx)
- Remove all toolbar action excluded bold, italic and udnerline:
[CODE]
<ajaxToolkit:HtmlEditorExtender ID="htmlEditorExtender2" TargetControlID="txtBox2"
runat="server" DisplaySourceTab="True" OnImageUploadComplete="ajaxFileUpload_OnUploadComplete">
<Toolbar>
<ajaxToolkit:Bold />
<ajaxToolkit:Italic />
<ajaxToolkit:Underline />
</Toolbar>
</ajaxToolkit:HtmlEditorExtender>
[/CODE]
- Write TWO lines content ie.:
"bla bla bla
gugugu"
- Click to submit content <- as you can see, content has been cleaned.
Workaround:
Add at least one justify action:
[CODE]
<Toolbar>
<ajaxToolkit:Bold />
<ajaxToolkit:Italic />
<ajaxToolkit:Underline />
<ajaxToolkit:HorizontalSeparator />
<ajaxToolkit:JustifyLeft />
</Toolbar>
[/CODE]
Comments: This happens because of the way HtmlEditorExtender performs sanitization on the Sample Site. If you copy-paste these two lines from this site to HtmlEditorExtender and switch to the source tab, you will notice that the content is enclosed into two __span__ elements. Before the sample page performs sanitization, it calls the MakeCombinedElementList() method to create a list of elements that will be kept untouched. This method loops through the toolbar buttons and adds white elements for each button on the list. As a result, this list can lack a __span __element and it will be removed after the sanitization. This completely removes all text, providing that all sample content consists of only two __span__ elements. However, this is not a bug. You can compose a white elements list in any way you want and pass it to a Sanitizer, so that the __span__ elements will not be removed.