Sometimes you may want to detect whether an EPiServer Block is being edited/previewed directly as opposed to just being rendered in a page that is being edited. For this purpose PageEditing.PageIsInEditMode is not enough.

My use case was rendering some editable properties in the block edit view outside of the rendered component, but not have those distort the layout when that block is rendered on a page being edited in a content area.

Here's what I want to achieve

Here's how to achieve it

Set up a base controller for all your preview controllers, in it set a ViewBag dynamic property of IsInBlockPreview (or similar) and then use this in your Block views to hide/show certain editor specific pieces.

Here's a gist...

Post comment