Thursday, November 6, 2008

DesignModeConsoleContainer vs EditModePanel - What's the Difference?

Maybe you've seen Microsoft.SharePoint.Publishing.WebControls.EditModePanel and the Microsoft.SharePoint.WebControls.DesignModeConsoleContainer as you're building your SharePoint layout pages. Maybe you've even seen one or the other as you're looking through some of the out of the box layout pages. If so (or even if you're just curious), you might find this information a little useful.

I've tried to find the difference between the two on the web, and the information just isn't there (like so many other things SharePoint.) As you can well imagine by the namespaces, the EditModePanel is comes from the Publishing namespace, which means you'll only see it if you're running Microsoft Office SharePoint Server. The other, the DesignModeConsoleContainer is from the WSS area, and comes standard as part of you WSS-enabled server.

As far as functionality goes, they're both designed to allow you to only show things when your page is in Design or Edit mode. This way, you can have some text or fields that you only want someone editing the page to see, but remain hidden from the average user.

Using either control is pretty straight forward: simply open one of the tags, put whatever controls you want inside it, then close the tag.

Examples:

<sharepointwebcontrols:designmodeconsolecontainer runat="server">
   You're in design mode
</sharepointwebcontrols:designmodeconsolecontainer>

or

<publishingwebcontrols:editmodepanel runat="server">
   You're in edit mode
</publishingwebcontrols:editmodepanel>

But, what--if any--is the difference between the two you might ask? Well, the DesignModeConsoleContainer is just a place to display stuff: text, images, special formatting, stuff like that. If you want to put editable fields in there, you need to use the EditModePanel. For some reason, the DesignModeConsoleContainer will seem like it works for fields, but none of the data will save if the user changes it.

For example, if you you want to allow users to fill in metadata for your pages that you don't want displayed on the page (i.e. select a region, assign a popularity rating, expiration date, rollup image, etc), place those fields inside of the EditModePanel. If you just want to display instructions for the person editing the page that will let them know about procedures for publishing a page, terms and conditions for pages or their site, or anything like that, you can put it in either control.

I hope this information saves other developers the time I spent trying to figure this out.
Happy coding!!

No comments: