SharePoint Custom Form Shows HTML as Text on Lookup Fields

Ivan Maksimov -

It may occurs on different display forms. In some case it happens after creating new DispForm view.

The problem is that lookup value include HTML tags.

Reason:

 The form displays text instead of the actual anchor tag. This is because the default output for the XSL transformation is to escape special characters. To address this, we need to modify the XSL template and force the output to render the HTML instead of displaying it as text. This can be done by adding the disable-output-escaping attribute to the xsl:value-of tag.

Soution:

 Open the code view of your form and look for the template that handles the rendering of the fields. Look for the field that has the problem and add the attribute. This is what the tag should look before and after the change:

 

Before

After

<xsl:value-of select="@FieldName" />

<xsl:value-of select="@FieldName" disable-output-escaping="yes"/>

 

Save your changes and refresh the page.

Have more questions? Submit a request

Comments

Powered by Zendesk