Tips for WCM (Web Content Management)

29 09 2008

Some time ago I had the chance to attend a workshop with Andrew Connell, regarding WCM (Web Content Management). Although we use slightly different approaches for packaging the solutions (I’m currently using WSPBuilder available codeplex), the remaining of the development process are pretty similar. I will address the process I’m currently using soon.

I would like to share with you some tricks I learned from that session:

  • GUIDS & “{}”: thumb rule for using “{}” in your GUIDs – If the GUID is referring a Column Definition it is mandatory; any other cases it is either optional or not used.
  • When you are defining a Content Type, you can add the property “DisplayName” to the FIELDREF tag in order to change the display name without changing the Column Definition.
  • You can use the same layout to several content types: on the layout installation, create several instances of the layout with several names
  • Iin order to work properly, the dlls used by layouts and master pages must be located in the GAC (Global Assembly Cache, p.e. c:\windows\assembly)
  • Whenever possible, use site templates (css + images) to customize a site. When that is not possible (most publishing sites), use master pages and page layouts.
  • you should locate branding files either at:
     – Style Library
      There isn’t a perfect solution. Consider backups, isolation, performance, cache, etc.

Great session and great book

Debugging tips for SharePoint

27 09 2008

I came accross a great post that realy reflects the Sharepoint day-by-day: debugging. You can find it at

Take a GOOD look at it. Follow any links to tools you don’t know yet.

Great post!

Faceted Search v2.5

26 09 2008

Here is a great tool. This used to imply a serious development time and now is packed and ready to use. Faceted search implements the concept of facets (groups of results according to topics) and implements :

  • Caching
  • Synchronization with Core Search Results web part
  • Support for advanced search
  • Match of search counters
  • Introducing Parent-Child relationships
  • Extending search to logical “OR” queries
  • Simplified web part properties

Check the full pot with samples and images at (

Using Team Foundation Server to Develop Custom SharePoint Products and Technologies Applications

26 09 2008

from the artticle:

Summary: Use Microsoft Visual Studio 2008 Team Foundation Server to support SharePoint application development, and provide an integrated development environment and single source code repository for process activities, integrated progress reporting, and team roles. (12 printed pages)

You can get it from

WSS 3.0 and MOSS 2007 SDK 1.4 Download and Online MSDN Library

26 09 2008

since 30/Aug, tehre is a new version of the SDK for WSS & MOSS.

Here is the information about it:

.. from the original post (

> Download the MOSS SDK 1.4 <

> Download the WSS SDK 1.4 <

The August 2008 update is version 1.4 and reflects feature enhancements that were part of the recent Infrastructure Update. For more information on SharePoint Products and Technologies updates, you can start here on TechNet.

Which SDK do I need to download?

If you are only writing code that utilizes the Windows SharePoint Services platform, you can download the WSS SDK. However, if you want the superset of all documentation and samples, you should install the MOSS SDK, and then you’ll get all the platform and technology information as well. You don’t need to download both, but you will need to uninstall all previous versions.

Note The SDK 1.4 downloads are full releases that include all previous tools and documentation.

What’s New in this release?

The SDK updates in 1.4 include:

While you’re updating your SharePoint development tools…

You can also update the Visual Studio Extensions for SharePoint Services. Here is the link to the installer: VSeWSS 1.2. The extensions were updated on 7/1/2008 and now work with Visual Studio 2008!

Don’t forget to download the user’s guide: version 1.1

Detecting the current mode (display/edit)

23 09 2008

One of these days I came accross a simple requirement that led me to a couple of scenarios: “How do I detect if I am in display mode or in edit mode?”. This has some significant importance in WCM (Web Content Management) world, where you may need some tricks to hide fields, controls or even alter the look of a component. Thhis can be achieved (at least) in three ways:

  • in the Layouts (aspx) code only:

In this case you have specific zones where to put controls that appear in edit mode and in display mode (

For any part you need to hide from Edit mode surround it by

<PublishingWebControls:EditModePanel runat=server id="EditModePanel1" PageDisplayMode="Display">
<!-- your code here -->

For any part you need to hide from Display mode surround it by

<PublishingWebControls:EditModePanel runat=server id="EditModePanel1" PageDisplayMode="Edit">
<!-- your code here -->
  • code behind: webparts

In this case, the object responsible for the information of the current mode is the WebPartManager.DisplayMode ( The allowued values for this enumerate are (from msdn):


Display mode Description
BrowseDisplayMode Displays Web Parts controls and UI elements in the normal mode in which end users view a page.
DesignDisplayMode Displays zone UI elements and enables users to drag Web Parts controls to change the layout of a page.
EditDisplayMode Displays special editing UI elements and enables end users to edit the controls on a page.
CatalogDisplayMode Displays special catalog UI elements and enables end users to add and remove page controls.
ConnectDisplayMode Displays special connections UI elements and enables end users to connect Web Parts controls.

Note that this only works correctly if there is only 1 webpart on the page as the test is done individually.

  • code behind: other situations

This is probably the least used mode, nevertheless, I had to used a couple of times. You can detect the current mode through:


This is an enumerate with the values:

  • SPControlMode.Display
  • SPControlMode.Edit

Thus you can build a very simple test:

  if (Microsoft.SharePoint.SPContext.Current.FormContext.FormMode == SPControlMode.Display)
   // your code to support display mode
  else // Microsoft.SharePoint.SPContext.Current.FormContext.FormMode = SPControlMode.Edit
   // your code to support edit mode

Code behind in layouts and master pages

22 09 2008

Something quite simple, but that has been asked me recurringly is the possibility of adding code behind to layouts and master pages. This is not only possible, but in many cases essential.
Remember that we are coding here, so you basically need to add a reference to where the code is 🙂

I found a simple sample from Connell at MSDN (

How you do it?
* create a class that inherits from the Microsoft.SharePoint.Publishing.PublishingLayoutPage class (or System.Web.UI.MasterPage if you are creating a code-behind file for a master page).
* add the class to the GAC or bin folder
* add the class to the safecontrols list on your web.config
* add a reference to the class on your master or page layout file

Note: for structuring purposes, you should name this class with the same name as the file.

Here is a sample c# class:
using System;
using System.Web.UI;
using Microsoft.SharePoint.Publishing;
namespace MSDN.SharePoint.Samples {
  public class PageLayoutTemplate : PublishingLayoutPage {

Here is how you can access it on the aspx or master file:

<%@ Page meta:progid="SharePoint.WebPartPages.Document" Language="C#"
Inherits="MSDN.SharePoint.Samples.ContentpageTemplate, MSDN.SharePoint.Samples.SharePointPagesWithCodeBehind, Version=, Culture=neutral, PublicKeyToken=ae015afe5f30fb68" %>
<%@ Master language="C#"
Inherits="MSDN.SharePoint.Samples.MinimalMasterTemplate, MSDN.SharePoint.Samples.SharePointPagesWithCodeBehind, Version=, Culture=neutral, PublicKeyToken=ae015afe5f30fb68" %>

[UPDATE] On the other hand, if you need to prototype something and don’t want to create a dll, deploy it, etc, you can just add the code to the aspx file as in this example:

<script  type="text/c#" runat="server">
    protected override void OnLoad(EventArgs e)
        // avoid processing if not in display mode
        if (Microsoft.SharePoint.SPContext.Current.FormContext.FormMode == SPControlMode.Display)
            // testing the query string.
            // this should be achieved through a configuration key in the web.config
            if (Request.QueryString.ToString().Contains("Mercados"))
                // show some; hide some other
                this.SummaryLinkFieldControl1.Visible = false;
                this.SummaryLinkFieldControl1.Visible = true;
                // hide some; show some other
                this.SummaryLinkFieldControl1.Visible = true;
                this.SummaryLinkFieldControl1.Visible = false;