0

I have below data stored in a rich text are field.

<html><head></head><body>Hello</body></html>

Controller

public with sharing class ContentController {
    public List<Content__c> contentList {get;set;} 
    public ContentController() {
        getContent();
    }
    private void getContent() {
        ContentList = [SELECT Id,HTMLContent__c,
                               FROM Content__c LIMIT 2];
    }
}

Page

<apex:outputText value="{!ContentList[0].Content__c}">
    escape="false"
</apex:outputText>

But when i render data in the page it is not displaying content, rather it is displaying html as a text. "<html><head></head><body>Hello</body></html>" Can anyone help me with this?

1
  • I tried to reproduce it, but it worked and rendered my hello. The only issues I had were problems you probably introduced when you wrote the question. Please consider editing your question to fix these errors, it won't compile like this! {!ContentList[0].Content__c} should be {!ContentList[0].HTMLContent__c} - there also is a comma too much in your SOQL , FROM Content__c and your escape="false" should be within the tag. Since I could not reproduce it, please provide more details about your problem.
    – itsmebasti
    Dec 4, 2017 at 17:13

1 Answer 1

2

This should work. For some reason you are doing the escape="false" at the wrong place

<apex:outputText value="{!ContentList[0].HTMLContent__c}" escape="false" />
5
  • I am using escape="false" within tag only, somehow it was not given properly here. But still i am not able to get the html content Dec 4, 2017 at 16:23
  • I'm not sure about this, the code does not change when you copy it here. I fixed the formatting of your post and saw, that the escape attribute was in the same line, but behind the tag: <apex:outputText value="{!ContentList[0].Content__c}"> escape="false"
    – itsmebasti
    Dec 4, 2017 at 16:40
  • But it is correctly given in my codebase, still it is not rendering Dec 4, 2017 at 16:46
  • Hm okay, are you sure it is not escaped in your field already?
    – itsmebasti
    Dec 4, 2017 at 16:58
  • In the fields it is stored like below, <html><head></head><body>Hello</body></html> Dec 4, 2017 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .