I am wondering if there is a way to set a class to a container div ONLY if in edit mode in EPiServer? I found this way to add a html-element:
@if (PageEditing.PageIsInEditMode) {
<p>I am in edit mode!</p>
}
But is there a way to do like this:
<div class="main-content @PageEditing.PageIsInEditMode ? 'edit-mode' : 'not-edit-mode'">
Lots of content here
</div>
For me that renders as:
<div class="main-content class ? 'edit-mode' : 'not-edit-mode'">
But there has to be a clever way to make this work?
You have to put parenthesis around it for the whole expression to be parsed, otherwise Razor stops parsing as soon as it can:
@(PageEditing.PageIsInEditMode ? "edit-mode" : "not-edit-mode")