I kicked my self today for forgetting a neat trick I learned earlier this year while working on a massive Intranet project in Jan, wasted almost a day and a  half to achieve the same effect via client side script (Javascript). 

If you have used any of the OOTB publishing layout pages then you would have noticed ‘EditControlPanel’ control. This is used to display meta data fields that need to be updated when in in page edit mode, i.e  when filling in the page content fields. You can also add text and images to help users out with content authoring. Now what ever you put between the opening and closing tags only gets displayed when the page is in edit mode and not in the preview or display mode.

But how can you invert the condition? For example show page fields only in display mode and not the edit mode? Well the answer is real simple just use the EditModePanel control again, it turns out that the control supports  an additional property called ‘PageDisplayMode’, via which you can control what gets displayed when, by default the elements value is set to Edit.

To Hide Content in Display Mode

<PublishingWebControls:EditModePanel runat=server id="EditModePanel1">
<CONENT GOES HERE>
</PublishingWebControls:EditModePanel>

To Hide Content in Edit Mode 

<PublishingWebControls:EditModePanel runat=server id="EditModePanel2" PageDisplayMode="Display">
<CONENT GOES HERE>
</PublishingWebControls:EditModePanel>

Advertisements