function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DipakDipak 

How to display HTML content in Visual force page

Hi Everybody,

 

I have created a VF page ccontroller(i.e a Apex class) which is returning a String Variable containing some HTML content,

 

But when i am displaying that String variable in VF page , it is showing the output in different format.

 

Example--

 

Apex class Code

 

String HTMLContent='<b>Hello World</b>'

 

public String getContent(){

return HTMLContent;

}

 

VisualForce Page Code

 

{!Content}

 

It is showing the output like that  "<b>Hello World</b>" 

But i want to display the Hello World in bold letter(like html format)

 

When i am execute and view the Page output in FireBug, The String is like that

 

&lt;b&gt;Hello World&nbsp&lt;/b&gt;

 

 

I need help,

Best Answer chosen by Admin (Salesforce Developers) 
hemantgarghemantgarg

Hi,

 

You have to use <apex:outputText value="{!content}" escape="false" />  on vf.


Dipak wrote:

Hi Everybody,

 

I have created a VF page ccontroller(i.e a Apex class) which is returning a String Variable containing some HTML content,

 

But when i am displaying that String variable in VF page , it is showing the output in different format.

 

Example--

 

Apex class Code

 

String HTMLContent='<b>Hello World</b>'

 

public String getContent(){

return HTMLContent;

}

 

VisualForce Page Code

 

{!Content}

 

It is showing the output like that  "<b>Hello World</b>" 

But i want to display the Hello World in bold letter(like html format)

 

When i am execute and view the Page output in FireBug, The String is like that

 

&lt;b&gt;Hello World&nbsp&lt;/b&gt;

 

 

I need help,




All Answers

hemantgarghemantgarg

Hi,

 

You have to use <apex:outputText value="{!content}" escape="false" />  on vf.


Dipak wrote:

Hi Everybody,

 

I have created a VF page ccontroller(i.e a Apex class) which is returning a String Variable containing some HTML content,

 

But when i am displaying that String variable in VF page , it is showing the output in different format.

 

Example--

 

Apex class Code

 

String HTMLContent='<b>Hello World</b>'

 

public String getContent(){

return HTMLContent;

}

 

VisualForce Page Code

 

{!Content}

 

It is showing the output like that  "<b>Hello World</b>" 

But i want to display the Hello World in bold letter(like html format)

 

When i am execute and view the Page output in FireBug, The String is like that

 

&lt;b&gt;Hello World&nbsp&lt;/b&gt;

 

 

I need help,




This was selected as the best answer
Richa KRicha K

Hi,

 

Wht type of fild type are you using? Rich text or Plain text?

DipakDipak

thanks

rak1rak1
I Displayed my HTML content from my custom object to VF page same as <apex:outputText value="{!content}" escape="false" />
It works fine, But in security scanner results, it shows as XSS_STORED error,
Can you please help me to overcome this issue