EPiServer Blocks: Render inline content

Assuming you have an EPiServer property called “CustomHtml” (XhtmlString) with the value “<p>Hello, world!</p>”, and you want to render it, what you will try is:

<div id=”contentHere”>

@Html.PropertyFor(x=>x.CustomHtml)

</div>

It will print out the whole XhtmlString as text, not as Html. For it to work, you need to mark up the Property as InlineContent:

@Html.PropertyFor(x=>x.CustomHtml, new {Tag=”InlineContent”})

You can also use the @Html.Raw(ViewBag.Something)

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s