Aidan Garnish

Collaboration Not Competition

Turn Off Custom Errors in MOSS 2007

To get the ASP.NET error message along with the call stack/stack trace do the following:

1. Navigate to the site directory.

2. Open web.config.

3. Switch Custom Errors off. Search for “customErrors” and set the value to “Off” instead of “On”.

4. Enable CallStack. Search for “CallStack” and set the value to “true” instead of “false”.

5. Save web.config.

A comprehensive guide to SharePoint debugging.

MOSS 2007 site definitions vs site templates

There are two confusing terms in MOSS 2007, site templates and site definitions. A site template is a .stp file which contains only the difference of changes from the original site definition. A user who wants to install a custom .stp file must have a site definition installed from which the .stp file was saved.

A site definition on the other hand is a complete definition with a directory structure containing .aspx files and a Onet.xml file.

For more on creating site definitions see Madhur Ahuja's post

Using SharePoint web services to get list items

A colleague has just been wrestling with the syntax to get the list items out of the XML returned by the SharePoint web services. These two blog postings helped hugely:

http://weblogs.asp.net/paulballard/archive/2005/05/08/Using-Data-From-SharePoint-2003-Lists.aspx

http://blogs.msdn.com/arpans/archive/2007/07/24/sharepoint-web-service-example-grabbing-wiki-content.aspx

UPDATE - I have posted a code snippet for retrieving items from a list using web services here

Custom SiteMapPath to handle variations in MOSS 2007

Whilst developing a MOSS 2007 Internet site I came across an issue with the SiteMapPath control when using variations. Variations use the root site to direct the user to the correct variation for their settings. A user with settings of en-GB, for example, will be directed towards the relevant variation by variationroot.aspx.

This is great except when using the SiteMapPath breadcrumb navigation control which displays the variation root site as well as the relevant variation site by default.

By default the following is displayed:

Variation Root > English Site > Some Page

What I want to display is:

English Site > Some Page

To achieve this I have created a server control that inherits from SiteMapPath and has an additional property called IgnoreNode. I have overridden the RenderContents event so that the HyperLink that has the same text as IgnoreNode is no longer rendered. In my case I set IgnoreNode to "Variation Root" so that it is not displayed in the breadcumb but you could choose any node that you don't want to display.

The code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CustomBreadcrumb
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:CustomBreadcrumb runat=server></{0}:CustomBreadcrumb>")]
    public class CustomBreadcrumb : SiteMapPath
    {
        [Bindable(true),
        Category("Data"),
        DefaultValue("")]
        public string IgnoreNode
        {
            get
            {
                object o = ViewState["IgnoreNode"];
                if (o != null)
                    return (string)o;
                else
                    return String.Empty;
            }

            set
            {
                ViewState["IgnoreNode"] = value;
            }
        }
       
       protected override void RenderContents(HtmlTextWriter output)
       {
          bool blnNodeWasIgnored = false;
          HyperLink hlLink;

          foreach (Control oControl in this.Controls)
          {
              SiteMapNodeItem oSiteMapNodeItem = (SiteMapNodeItem)oControl;

              foreach (Control aControl in oSiteMapNodeItem.Controls)
              {
                  if(aControl.GetType().ToString() == "System.Web.UI.WebControls.HyperLink")
                  {
                      hlLink = (HyperLink)aControl;

                      if (hlLink.Text == IgnoreNode)
                      {
                         //don't call render
                          blnNodeWasIgnored = true;
                      }
                      else
                      {
                          aControl.RenderControl(output);
                          blnNodeWasIgnored = false;
                      }
                  }

                  if (aControl.GetType().ToString() == "System.Web.UI.WebControls.Literal")
                  {
                      if (blnNodeWasIgnored == true)
                      {
                          //don't render the seperator
                      }
                      else
                      {
                          aControl.RenderControl(output);
                      }
                  }
              }                  
          }
       }
    }
}

To deploy this control it needs to be strongly named and installed to the GAC using gacutil.exe

An entry in the web.config of your web application needs to be added:

<SafeControl Assembly="CustomBreadcrumb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=91e52569228df0da" Namespace="CustomBreadcrumb" TypeName="*" Safe="True" />

(Use reflector to find out the public key token of your dll.)

Restart IIS or even better recycle the relevant application pool.

You will need to register the control by adding the following line in the master page:

<%@ Register TagPrefix="adg" Namespace="CustomBreadcrumb" Assembly="CustomBreadcrumb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=91e52569228df0da" %>

Finally add the control to your master page, publish and approve the page.

Book review - Microsoft SharePoint Building Office 2007 Solutions in C# 2005 - Scott Hillier

Microsoft SharePoint Building Office 2007 Solutions in C# 2005 is an ideal book for people who are entirely new to SharePoint and also for those who are familiar with SharePoint 2003 and want to get up to speed quickly with the new functionality and features of MOSS 2007. Scott Hillier starts right from the beginning and addresses many of the common issues faced by people looking to utilise MOSS 2007 within their organisation.

He begins by looking at the none technical aspects of adopting MOSS and has some great advice on how to go about getting people to buy in to the relatively new concept of using business configurable IT tools to facilitate collaborative working. Once that is done he moves straight on to a step by step guide to installing MOSS 2007 which gets you up and running with a useable system very quickly. The remainder of the book is devoted to the many and varied features of MOSS 2007. This is a huge product that now includes the Web Content Management that was previously found in CMS 2002. Add to this the ability to use Windows Workflow Foundation to incorporate workflows into your sites and the new concept of packaging functionality up as features and you can appreciate that it must have been a real challenge to fit all of this into one book.

Whilst no one area is covered in a massive amount of detail the book gives enough information to get started looking at almost all aspects of what MOSS 2007 has to offer. Having already had experience of SharePoint 2003 I was looking for a book that would quickly bring me up to speed with the new functionality on offer and this book really delivers that. It is written with a clear and concise style that is very easy to read and understand. Step by step guides are provided along with plenty of screenshots making the workshop sections of the book easy to follow and complete.

If you are looking for a way to get a good working overview of what is available in MOSS 2007, packaged in a way that will take you right from start to finish then this is the book for you.

SharePoint 2007 Features on CodePlex

Features project on CodePlex:

Project Description
This is a project for SharePoint 2007 Features. Features add new functionality to a SharePoint 2007 farm, site collection, or site. This project will create Features to address deficiencies in SharePoint 2007 or add new capabilities. You should understand a little about Features before trying these out. The packages here use batch files or WSP files to install the Features. After installation, be sure to activate the Features to see them in SharePoint.

http://www.codeplex.com/features

MOSS 2007 governance

It isn't enough to have a thorough technical understanding of MOSS 2007 to achieve a successful implementation. To be truly successful the implementation needs to be carefully managed. Microsoft have produced a useful checklist to make sure you have considered the issues surrounding governance and control of your MOSS 2007 server farms.