已答复 Publishing HTML and RichTextField display HTML code - not rendering

  • 10/جمادى الأولى/1432 09:20 ص
     
     

    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

     

جميع الردود

  • 10/جمادى الأولى/1432 09:37 ص
     
     

    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

  • 10/جمادى الأولى/1432 10:24 ص
     
     الإجابة

    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

     

     


    • تم وضع علامة كإجابة بواسطة MikebEdwards 10/جمادى الأولى/1432 10:50 ص
    •  
  • 20/رجب/1432 07:53 ص
     
     إجابة مقترحة

    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

    • تم الاقتراح كإجابة بواسطة Octavie 20/رجب/1432 08:33 ص
    •  
  • 04/رمضان/1432 07:16 م
     
     

    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...

  • 16/ربيع الثاني/1433 11:22 م
     
     

    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?


     
  • 13/جمادى الأولى/1433 11:01 م
     
     إجابة مقترحة

    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

    • تم الاقتراح كإجابة بواسطة Pawan Upadhyay 20/جمادى الثانية/1433 12:47 م
    •  
  • 20/جمادى الثانية/1433 12:48 م
     
     

    Thanks Kevin...! Your solution works for me.

    -Pawan

  • 08/ذو الحجة/1433 07:36 ص
     
     
    Thx for this post. This works for me! Keep up the good work!!