Thursday, March 19, 2009

Showing the page fields/Controls only in edit mode of the SharePoint page

To show the fields only in the Edit mode of the page, add the controls in the following node by editing the page layout of the page.

PublishingWebControls:EditModePanel control is used to show the controls only in the edit mode of the page.

The way we do this is by putting two edit mode panels on the page layout, one configured to render in edit mode, and another configured to render in view mode:

To show in view mode
<
PublishingWebControls:EditModePanel runat=server id="EditModePanelA" PageDisplayMode="Display">
<
SharePointWebControls:FieldValue runat="server" id="ImageFieldValue" FieldName="PublishingPageImage"/>
PublishingWebControls:EditModePanel>

To show in Edit mode only
<
PublishingWebControls:EditModePanel runat=server id="EditModePanelB">
<
SharePointWebControls:FieldValue id="ContactEMailId" FieldName="ContactEMail" runat="server" />
PublishingWebControls:EditModePanel>


The first one will render its contents when people are viewing the page, while the second one will render when people are editing the page

No comments: