I have a webpage that has a htmleditor provided by the Ajax Control Toolkit. It works good in IE. I've tried all the buttons, and the underlying text is neatly stored in the database, including the tags for bold, font-size etc.
Now I've found out that Google Chrome works fine with bold for example, but completely ignores font-size or font-family.
The moment I highlight a piece of text and choose an button, it is fine. The moment I save it, it is gone.
By the way, font-size works fine in Firefox, font-family is also ignored.
I really need to get this working. Anyone any ideas?
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
That;s because you set EnableSanitization to false. But if you do that, no content is checked. Leaving it open for malicious attacks and copied text from example Word.
It's a bit strange that sanitation filters out function from the editor itself.
When the
EnableSanitization is set to true. Only the size 7 is ignored in Chrome. Other style is fine.
In IE the size 7 is saved as : “font size ="7""
In Chrome size 7 is saved as :
“font-size: xxx-large”
But it is should be : “font-size: -webkit-xxx-large”
That’s the reason why the font-size is ignored.
Best Regards,
Dillion
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Did you try to save the text? With a alert on client-side I can the spans Chrome creates, but the moment I get in my code behind, all the spans and so on are gone, leaving only plain text.
Maybe it has something to do with the fact that the editor is doing some decoding behind the scene? Because when I, on client-side, with jQuery, use the following command: $("#txtVoorlooptekst").text() all
I get are the empty spans and the styles are gone.
The code that Chrome generates is, style="font-family: "times new roman", times, serif;" so I think that the middle " are causing the problem. But since there are also legitime " in the text, I can't just filter them out.
Mayb
so I think that the middle " are causing the problem. But since there are also legitime " in the text, I can't just filter them out.
I have made a test. when the EnableSanitization is set to true, it will only remove the tags and the text in your tags.
I have set font-family, background -color ,and put some tags in text.
when I pass it to behind code, the text not in tags and the style are remained
And it’s the result:
I think the problem may caused by the Sanitizer.
What’s your version?
Mine AjaxControlToolkit and Sanitizer version is 16.1.1
Best regards,
Dilion
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
I've installed the latest version through the NuGet Package Manager Console in Visual Studio.
But I've discovered that the problem is that Chrome translates a font to <span style=font-family... and IE as <font face=... And that a different font-size is <span style="font-size... in Chrome and <font size=... in IE. And indeed, extra quotes
I've tried to make a sort of sanitizer myself as a workaround, but that takes to much time and needs a lot of testing.
Member
5 Points
39 Posts
Chrome ignores font-size in the htmleditor in the ajaxcontroltoolkit
Feb 14, 2017 11:00 AM|EllenHeijmans|LINK
I have a webpage that has a htmleditor provided by the Ajax Control Toolkit. It works good in IE. I've tried all the buttons, and the underlying text is neatly stored in the database, including the tags for bold, font-size etc.
Now I've found out that Google Chrome works fine with bold for example, but completely ignores font-size or font-family.
The moment I highlight a piece of text and choose an button, it is fine. The moment I save it, it is gone.
By the way, font-size works fine in Firefox, font-family is also ignored.
I really need to get this working. Anyone any ideas?
All-Star
45489 Points
7008 Posts
Microsoft
Re: Chrome ignores font-size in the htmleditor in the ajaxcontroltoolkit
Feb 15, 2017 06:28 AM|Zhi Lv - MSFT|LINK
Hi EllenHeijmans,
Does it also worked well in Chrome?
If it is, I think the problem is how you display the text.
I’m using the following code. It is worked in Chrome.
In aspx:
In behind code:
Best regards,
Dillion
Member
5 Points
39 Posts
Re: Chrome ignores font-size in the htmleditor in the ajaxcontroltoolkit
Feb 15, 2017 10:18 AM|EllenHeijmans|LINK
That;s because you set EnableSanitization to false. But if you do that, no content is checked. Leaving it open for malicious attacks and copied text from example Word.
It's a bit strange that sanitation filters out function from the editor itself.
All-Star
45489 Points
7008 Posts
Microsoft
Re: Chrome ignores font-size in the htmleditor in the ajaxcontroltoolkit
Feb 16, 2017 06:29 AM|Zhi Lv - MSFT|LINK
Hi EllenHeijmans,
When the EnableSanitization is set to true. Only the size 7 is ignored in Chrome. Other style is fine.
In IE the size 7 is saved as : “font size ="7""
In Chrome size 7 is saved as : “font-size: xxx-large”
But it is should be : “font-size: -webkit-xxx-large”
That’s the reason why the font-size is ignored.
Best Regards,
Dillion
Member
5 Points
39 Posts
Re: Chrome ignores font-size in the htmleditor in the ajaxcontroltoolkit
Feb 16, 2017 07:42 AM|EllenHeijmans|LINK
Did you try to save the text? With a alert on client-side I can the spans Chrome creates, but the moment I get in my code behind, all the spans and so on are gone, leaving only plain text.
Member
5 Points
39 Posts
Re: Chrome ignores font-size in the htmleditor in the ajaxcontroltoolkit
Feb 16, 2017 07:56 AM|EllenHeijmans|LINK
Maybe it has something to do with the fact that the editor is doing some decoding behind the scene? Because when I, on client-side, with jQuery, use the following command: $("#txtVoorlooptekst").text() all I get are the empty spans and the styles are gone.
The code that Chrome generates is, style="font-family: "times new roman", times, serif;" so I think that the middle " are causing the problem. But since there are also legitime " in the text, I can't just filter them out.
Mayb
All-Star
45489 Points
7008 Posts
Microsoft
Re: Chrome ignores font-size in the htmleditor in the ajaxcontroltoolkit
Feb 21, 2017 07:07 AM|Zhi Lv - MSFT|LINK
HI EllenHeijmans,
I have made a test. when the EnableSanitization is set to true, it will only remove the tags and the text in your tags.
I have set font-family, background -color ,and put some tags in text.
when I pass it to behind code, the text not in tags and the style are remained
And it’s the result:
I think the problem may caused by the Sanitizer.
What’s your version?
Mine AjaxControlToolkit and Sanitizer version is 16.1.1
Best regards,
Dilion
Member
5 Points
39 Posts
Re: Chrome ignores font-size in the htmleditor in the ajaxcontroltoolkit
Feb 22, 2017 09:28 AM|EllenHeijmans|LINK
I've installed the latest version through the NuGet Package Manager Console in Visual Studio.
But I've discovered that the problem is that Chrome translates a font to <span style=font-family... and IE as <font face=... And that a different font-size is <span style="font-size... in Chrome and <font size=... in IE. And indeed, extra quotes
I've tried to make a sort of sanitizer myself as a workaround, but that takes to much time and needs a lot of testing.
So I've decided to give up and buy a good editor.