3

I'm wondering if there are any differences between retrieving value of a site column (RichHtmlField) via PublishingWebControls:RichHtmlField vs getting its value via Container.DataItem?

<ItemTemplate>
    <div runat="server">
    <%# ((SPListItem)Container.DataItem)["SP_COLUMN_NAME"]%>
    </div>     
</ItemTemplate>

vs

<PublishingWebControls:RichHtmlField ID="..." FieldName="SP_COLUMN_NAME" ... ></PublishingWebControls:RichHtmlField>

I'm wondering about this because I'm retrieving value of a specific site column of type RichHtmlField in visual web part using CAML query and binding value of that column to ListView. It's working properly, but I found that if I added CEWP inside RichHtmlField, the content of CEWP is not rendered (I found later that content of CEWP is rendered before the end of page wrapped in hidden div). I'm using CEWP for embedding youtube video in page following this solution. But while viewing the column value via PublishingWebControls:RichHtmlField control it's working properly without any issues.

Any suggestions?

1
  • Did you try <SharePointWebControls:FieldValue FieldName="SP_COLUMN_NAME" runat="server" />
    – Oddmar Dam
    Commented Oct 22, 2012 at 12:27

1 Answer 1

1

The "PublishingWebControls:RichHtmlField" control is capable of rendering field data, not web parts -- I think this is where the confusion is coming from. In my experience, the data coming from code-behind vs. declarative have been the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.