forge

Picking up the SharePoint Services Navigation Controls

When you get into modifying site definitions you’ll run into a few interesting challenges.  Not the least of which are all of the different versions of a page that you’ll have to update in order to make the whole site to fit together.  One of the interesting aspects is the list pages.  Each list has it’s own set of pages.

On those list pages are some web controls that control view navigation and another one that controls the related links — both of them are on the left side of the page.  If you want to get to one master page without modifications these web controls present a problem.  (In other words, I want to manage one aspx page and be able to copy that into each of the files in each of the lists.)  Those pesky web controls make that not possible.

However, there is a solution.  You can encapsulate the ViewNavigation and RelatedLinks classes in the Microsoft.SharePoint assembly into web parts and use them as web parts.  In that way, you can change the left column to a site navigation web part zone and then insert web parts for ViewNavigation and RelatedLinks on the pages that happen to be list pages.  Then you can insert your own navigation above or below these standard web controls — and you can swap them out later without having to deal with the “thou shall not modify a site definition after it has been created rule.”  (I may have paraphrased that a bit.)

In general it looks like the WebControls in the Microsoft.SharePoint.WebControls namespace will encapsulate well into web parts so you can reuse the built in web controls — even if you want to move to a web part basic design.

Help Your SharePoint User

As a sidebar, the Microsoft.SharePoint.Portal.WebControls seem to all derive from WebPart so you won’t even have to encapsulate them.  All that’s necessary there is to create a DWP file.

The common administrative pages are still a challenge — but it’s getting easier bit by bit to create a cohesive site definition.

By the way, here’s the entire file I used to encapsulate the RelatedTasks web control…

using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;

namespace SPBuiltInControls
{
/// <summary>
/// Shell for Related Tasks web Control
/// </summary>
[ToolboxData(“<{0}:RelatedTasks runat=server></{0}:RelatedTasks>”),
XmlRoot(Namespace=”SPBuiltInControls”)]
public class RelatedTasks : Microsoft.SharePoint.WebPartPages.WebPart
{
protected override void CreateChildControls()
{
base.CreateChildControls ();
Microsoft.SharePoint.WebControls.RelatedTasks related = new Microsoft.SharePoint.WebControls.RelatedTasks();
Controls.Add(related);
}
}
}

… I got lazy and didn’t even bother removing the extra using statements…