Angus Logan

MCMS/SPS/.NET/SQL/Microsoft Australia

Help My HtmlPlaceholder content has been garbled by the radEditor using 'AllowSpecialTags'

If you use the Telerik radEditor and you have enabled 'AllowSpecialTags' on the placeholder control the Html is 'escaped' before it is saved to the database. The <'s and >'s are replaced with ~LT~ and ~GT~. This is all good when you use the radEditor to author the content and use it to display the content (ie. in presentation mode) ; But - when you retrieve the HtmlPlaceholder contents via code (ie. for aggregation or content reuse) :-

dim strHtml as String = Ctype(CmsHttpContext.Current.Posting.Placeholders("PlaceholderName"), HtmlPlaceholder).Html

You will see the Html content should be: Angus Logan but it comes out as ~LT~b~GT~Angus Logan~LT~/b~GT~. There are a few ways around this... you could replace the value when you retrieve it from the placeholder

strHtml = strHtml.Replace("~LT~","<").Replace("~GT~",">")

I don't think that is very elegant as you need to do it all over the place.

So I wrote a HtmlModule that I've uploaded to GotDotNet.

This HttpModule can also be used to replace any set of characters with another set configured in the web.config.

eg. I could replace any output that would usually be “Angus Logan“ to be “Angus Logan Rocks

<appSettings>

    <add key="AngusLogan.Cms.Utilities.CleanTelerikOutput.CharRewriteHttpModule" value="~LT~,&lt;|~GT~,&gt;|Angus Logan,Angus Logan Rocks" /><!-- "Old Value,New Value|Old Value,New Value" -->

</appSettings>