none
Publishing HTML and RichTextField display HTML code - not rendering

    Question

  • Hi there, 

    I have several custom columns of type "Publishing HTML", and a page layout several controls which point to the columns. :

    <SharePointWebControls:RichTextField DisableInputFieldLabel="True"  FieldName="WheelImage" runat="server"></SharePointWebControls:RichTextField>

     

    The problem is that in the end result, the page shows escaped HTML (eg. <p></p>) rather than the rendered output I would expect. 

     

    Oddly - when it edit mode - they render fine, showing the rendered output. But in the 'reader' view, it shows the raw HTML. 

     

    I have also checked the 'edit html source' in edit mode - and it looks fine, like HTML. But the browser source of the output page shows escaped html: &lt;br/&gt;

     

    I found this describing the same problem, but its not a solution - as this happens on any browser:

     

    http://social.msdn.microsoft.com/Forums/en/sharepointgeneral/thread/a7ab3a61-6643-4a47-a464-fe46b5db1558

     

    Anyone any ideas?

     

    Thanks

     

    Mike

     

    Thursday, April 14, 2011 9:20 AM

Answers

  • I think I got it. 

     

    When setting up this site - I had added the columns directly to the site, and not to the content type at the root of the site.

     

    When I add tyhe colums to a custom content type - and then add that content type to the site (rather than the individual columns) - it works. 

     

    I have no idea why this would result in it rendering encoded HTML, but it seems to have that effect.

     

    Mike

     

     


    • Marked as answer by MikebEdwards Thursday, April 14, 2011 10:50 AM
    Thursday, April 14, 2011 10:24 AM

All replies

  • I have used the U2U CAML Query builder software to query what is actually being stored - and it is html tags as you would expect:

     

    <p><b>TITLE</b></p>

     

    But at the front end, this is being sent to the browser as:

     

    &lt;p&gt;&lt;b&gtTITLE;&lt;/b&gt;&lt;/p&gt;

     

    But oddly - not on "edit mode" - where it displays as normal.

     

    Mike

    Thursday, April 14, 2011 9:37 AM
  • I think I got it. 

     

    When setting up this site - I had added the columns directly to the site, and not to the content type at the root of the site.

     

    When I add tyhe colums to a custom content type - and then add that content type to the site (rather than the individual columns) - it works. 

     

    I have no idea why this would result in it rendering encoded HTML, but it seems to have that effect.

     

    Mike

     

     


    • Marked as answer by MikebEdwards Thursday, April 14, 2011 10:50 AM
    Thursday, April 14, 2011 10:24 AM
  • I know, I got it.. ;)

    This morning I ran into the same problem. The solution is as follows:

    Do not use Multiple Lines of Text for the site column and also do not use <SharePointWebControls:RichTextField> in the page layout, because the Ribbon is not activated for formatting. These settings are more MOSS2007 like.

    What should you use?

    For the Site Column : Publishing HTML (Full HTML content with formatting and constraints for publishing)

    For the Page Layout: <PublishingWebControls:RichHtmlField>

     

    Good luck!

    Octavie

    • Proposed as answer by Octavie Wednesday, June 22, 2011 8:33 AM
    Wednesday, June 22, 2011 7:53 AM
  • Does not work for me.. I still see encoded text.

    I have Page Content 2 and Page Content 3 as site columns(Publishing HTML) and they are added to page layout(PublishingWebControls:RichHtmlField). Worked on 2007 but when I moved to 2010 started having problems...

    Thursday, August 04, 2011 7:16 PM
  • Hey Mike I am having this exact problem but I do not follow your solution? Do you mean you manually added columns to the site via Sharepoint Designer or something? In my case I created a custome Page layout with html controls like this

    <PublishingWebControls:RichHtmlFieldID="RichHtmlField3"FieldName="ContentColumn3"runat="server"/>

    I then created a Custom Content type with fields like this

    <FieldID="{48EDFBC2-A9A5-4C4E-B901-8A176E1473AF}"Name="HPLContentColumn3"DisplayName="Column1"Group="HPLColumns"Type="HTML"Required="FALSE"Sealed="FALSE"Hidden="FALSE"RichText="TRUE"RichTextMode="FullHtml"/>

    fields I then added them to my site via my WSP. But whenever I create a new page and assign it's pagelayout to be my custom one I still get your situation where it looks good in edit mode but it is escaped as text in the reader view. From what you said and I've read other places I am not seeing what I am missing. Can you help?


     
    Friday, March 09, 2012 11:22 PM
  • I had a similar experience as you; I had multiple RichHtmlFields on my page, and one was displaying correctly while another was not.  When I viewed the fields via the powershell, I noticed a difference in the SchemaXML, the WORKING field had the following additional properties:

         RichText="True"
         RichTextMode="FullHtml"

    I wrote a quick script to update the problem field, and the problem went away for me (look below for script). The change has to be made at the list level for it to take affect on existing pages/lists, but I believe making the modification to the column at the root web (or correct subweb) would work as well.

         $web = $site.OpenWeb($site.RootWeb.ID)
         $list = $web.Lists["Pages"]
         [Microsoft.SharePoint.Publishing.Fields.HtmlField]$field =   [Microsoft.SharePoint.Publishing.Fields.HtmlField]$list.Fields.GetFieldByInternalName("Abst     ract")
         $field.RichText = $true
         $field.RichTextMode = [Microsoft.SharePoint.SPRichTextMode]::FullHtml
         $field.Update()
         $list.Update()

    You may want to check your field to make sure those properties are set.  Hope that helps!


    Kevin

    Thursday, April 05, 2012 11:01 PM
  • Thanks Kevin...! Your solution works for me.

    -Pawan

    Friday, May 11, 2012 12:48 PM
  • Thx for this post. This works for me! Keep up the good work!!
    Wednesday, October 24, 2012 7:36 AM
  • This worked for me. I had to use SharePoint Manager 2013 (migrating from SP2007 to SP2013) and I also had to change the settings on the field on the Library itself. Though my Pages library use the field from the Content type, changing on the content type alone had no affect.

    Great post.

    Sunday, December 15, 2013 10:20 PM