Article Author: Mark Gerow
Introduction
SharePoint 2007 (I use the term here to refer to both Microsoft Office SharePoint Server 2007 and Windows SharePoint Services 3.0) will not only change the way you develop in SharePoint, but will change the way ASP.NET applications are developed in general. SharePoint 2007 has recently been released but the code with this article was tested with the Beta 2 technical refresh. The purpose of this article is to survey what I believe are "must know" new features which will give you a jump-start in evaluating and mastering the new version.
Specifically, I will cover:
- Business Data Catalog (Office SharePoint Server 2007 only)
- Event handler enhancements
- Extensible workflow
- Item-level security
- Simplified web part development using ASP.NET 2.0
Note: in this article I assume that you are already familiar with the basic features in SharePoint 2003, and so I won’t spend a lot of time explaining what these features are and how they work. If you feel you need more grounding in SharePoint basics there are many excellent books on the subject, including several titles from Apress (www.apress.com).
After reading this article you should be able to explain clearly to your colleagues, management, and clients how these new features fit into your overall SharePoint and ASP.NET 2.0 deployment strategy.
System Requirements
Although this article doesn’t address programming against SharePoint, you will probably want to obtain a copy of the software to try it out for yourself. For most of the topics covered you only need Microsoft Windows Server 2003 (Standard or Enterprise) and WSS 3.0, not MOSS 2007 – which runs on top of WSS 3.0
As part of the WSS 3.0 installation process the following components will be installed:
- .NET 2.0 or .NET 3.0
- SQL Server 2005 Express Edition (if you already have SQL Server 2005 you can use that rather than the "Express" edition)
- Windows Workflow Foundation beta
If you plan to create custom web parts or .NET applications that access the object model you will also want to install Visual Studio 2005.
Business Data Catalog
If your firm is like mine, one of the first things you did (or want to do) with SharePoint is to present an integrated view of data from the many disparate systems that store bits and pieces of your business’ data. SharePoint can be a great tool for bringing together financial, client relationship, document management, and workflow systems into a single unified view. To achieve this goal you must extract the data from each of the source systems and convert it ultimately into HTML that can be displayed on the page. The Business Data Catalog (BDC) feature of MOSS 2007 attempts to address this common need by creating a metadata catalog that commercial software vendors and in-house developers can use to store information about data sources. Microsoft also provides a set of basic web parts that non-technical users can configure to query, display, and connect data sources defined in the BDC.
Note: the Business Data Catalog is a feature of Microsoft Office SharePoint Server 2007, and will not be available if you only install Windows SharePoint Services 3.0.
To provide a simple example of how the BDC is configured and used, I will create a simple SQL Server table, register it in the BDC, and display it on a web part page using one of the BDC web parts provided by Microsoft.
First, I’ll create a BDC definition for a simple SQL Server table shown in Figure 1:

Figure 1. Sample database table used to demonstrate BDC
This figure has been reduced in size to fit in the text. To view the full image Click here
By way of an example I include a fragment of a BDC schema for the above data source. The schema XML is read by SharePoint to create the definition of the data source that can be used by the BDC web parts or BDC classes in the object model.
<?xml version="1.0" encoding="utf-8" ?>
<LobSystem Name="BDC_TEST" Version="1.0.0.0"
xmlns="http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog"
Type="Database"> <Properties> <Property Name="WildcardCharacter" Type="System.String">%</Property> </Properties> <!— Describe how to connect to the database —> <LobSystemInstances> <LobSystemInstance Name="BDC_TEST_INSTANCE1"> <Properties> <Property Name="AuthenticationMode" Type="System.String"> PassThrough </Property> </Properties> </LobSystemInstance> </LobSystemInstances> <!— Describe the queries or tables that are available —> <Entities> <Entity Name="Table_1"> <!— How will a row be uniquely identified —> <Identifiers> <Identifier Name="ID" TypeName="System.Int32" /> </Identifiers> <Methods> <Method Name="GetData"> <Properties> <!— SQL query to return the data—> <Property Name="RdbCommandText" Type="System.String"> SELECT ID,Name,Notes from Table_1 where Name LIKEName </Property> </Properties> <FilterDescriptors> <FilterDescriptor Type="Wildcard" Name="Name"> <Properties> <Property Name="UsedForDisambiguation" Type="System.Boolean">True </Property> </Properties> </FilterDescriptor> </FilterDescriptors> <Parameters> <Parameter Direction="In" Name="Name"> </Parameters> <MethodInstances> <MethodInstance Name="DataFinderInstance" Type="Finder" ReturnParameterName="Data" /> </MethodInstances> </Method> </Methods> <Actions> <Action Name="Tell me more?" Position="1" IsOpenedInNewWindow="true" Url="javascript:alert(‘You clicked on {0}!’)" ImageUrl=""> <ActionParameters> <ActionParameter Name="Name" Index="0" /> </ActionParameters> </Action> </Actions> </Entity> </Entities> </LobSystem>
The above listing is incomplete, but it gives you a sense of the challenge inherent in defining even a simple schema. This difficulty notwithstanding, Microsoft and others will undoubtedly create GUI schema designers to produce the necessary XML. In the meantime, Microsoft provides an XML schema file (.XSD) to help us pioneers create schemas using just Visual Studio 2005. Figure 2 shows the BDC in action using the built-in BDC list web part.

Figure 2. The BDC list web part
This figure has been reduced in size to fit in the text. To view the full image Click here
While this example is absurdly simple, you can imagine creating (or purchasing) a library of schemas for both custom and commercial applications that allow your users to easily query and display data from a variety of systems. I don’t doubt that, in many firms, the BDC will become one of the most valuable features of Office SharePoint Server 2007.
Event Handlers
In SharePoint 2003 only document and form libraries supported custom event handlers, and only a very limited set at that. In SharePoint 2007 all list types support an expanded set of events. This expansion in event handling will undoubtedly lead to a dramatic increase in the use of SharePoint 2007 as a business workflow platform. The following table lists the workflow events to which you can attach handlers in SharePoint 2003 and will be available in SharePoint 2007 when released:
| Event | SharePoint 2003 | SharePoint 2007 | Type |
|---|---|---|---|
| Before item is added | No | All list types | Synchronous |
| After item is added | Document and forms libraries only | All list types | Asynchronous |
| Before item is changed | No | All list types | Synchronous |
| After item is added | Document and forms libraries only | All list types | Asynchronous |
| Before item is deleted | No | All list types | Synchronous |
| After item is deleted | Document and forms libraries only | All list types | Asynchronous |
Note the two types of events: asynchronous and synchronous. Microsoft defines synchronous list events are those that occur before an action is taken (e.g. deleting a list item). In such a case your event handler must complete prior to the triggering action and you have the option of canceling that action. For example, you could determine that based on some business rules, that a user’s updates to a list are invalid and should not be applied. You now have the ability to cancel their updates and display an error message. SharePoint 2003 only provided asynchronous events that fired after the action has occurred, thus requiring awkward workarounds in code if the action preceding the event needed to be cancelled.
To code a SharePoint 2007 event handler in .NET, you create a server control class that implements the SPItemEventReceiver interface. Writing your event handler is fairly straightforward as the overridable methods in the SPItemEventReceiver interface expose the list item on which the event occurred, so you can manipulate it using other SharePoint or standard .NET classes and methods. As with SharePoint 2003, your event handler must be strongly named and reside in the GAC.
While SharePoint 2007 events can be registered using the same procedure used in SharePoint 2003, Microsoft recommends a new approach that utilizes Features, which are a declarative model for defining extensions to SharePoint. With this approach you first define the feature using XML, as shown below.
<Feature Scope="Web" Title="Deleting Event Handler" Id="GUID" xmlns="http://schemas.microsoft.com/sharepoint/"> <ElementManifests> <ElementManifest Location="Elements.xml"/> </ElementManifests>
</Feature>
Note: This example draws on sample code from the SDK.
Then you define Elements of the feature, such as,
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="104">
<Receiver>
<Name>DeletingEventHandler</Name>
<Type>ItemDeleting</Type>
<SequenceNumber>10000</SequenceNumber>
<Assembly>DeletingEventHandler, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=a26b5449ac4a4cf3</Assembly>
<Class>DeletingEventHandler.DeletingAction</Class>
<Data></Data>
<Filter></Filter>
</Receiver>
</Receivers>
</Elements>
These definition files are then imported into SharePoint and associated with one or more lists.
Note: There are also events that fire before sites or site collections are deleted, allowing you to ensure proper archiving of sites.
Extensible Workflow
Picking up where custom event handlers leave off, SharePoint 2007 supports complex workflow processes using the new Windows Workflow Foundation. You can author workflows in either Visual Studio 2005 or SharePoint Designer 2007 (the new name for FrontPage). Not surprisingly, creating workflows is simpler in SharePoint Designer, but you have much more flexibility and control in Visual Studio.
Figure 3 gives you a sense of how workflows are defined in SharePoint Designer 2007. The process is essentially a fill-in-the-blanks affair, which makes it simple to get started.

Figure 3. Defining a workflow in SharePoint Designer 2007
After the workflow above has been saved in SharePoint Designer (and automatically deployed to a SharePoint site), it will check the Title field any time a document is added or modified. If the text Hello World! is found the workflow engine will change it to Hi There!.
What Microsoft and many others have observed is that application development can benefit by separating the flow-of-control logic (i.e workflow) from the code that gets executed at each flow state (i.e. activities). You will see this approach begin to permeate all .NET development, not just SharePoint.
Item-level Security
This enhancement moves SharePoint closer to the realm of true document management systems (a fact that is not lost on DMS vendors). In SharePoint 2007 you will be able to set permissions on a list, a folder, or on individual documents. In contrast SharePoint 2003 lists only supported security at the list level. Combined with the new security trimming feature, which hides list items from users who don’t have permissions to access them, SharePoint 2007 provides a basic but serviceable DMS. Considering that the cost of a mid-range DMS system starts at several hundred thousand dollars, many firms may seriously consider SharePoint 2007 as their only DMS platform.
As Figure 4 shows, the context menu for individual list items now allows you to set permissions (and alerts) for just that item. For practical reasons you probably want to use this feature sparingly, as security administration could become a real burden if most of your documents have unique permissions, but the addition of this capability will answer many objections that have been raised against using SharePoint as a general-purpose document management solution.

Figure 4. Setting individual list item permissions in SharePoint 2007
This figure has been reduced in size to fit in the text. To view the full image Click here
Simplified Web Part Development using ASP.NET 2.0
In SharePoint 2003 creating your first web part was a true right of passage. Especially in the early days just after its release, with little documentation and no Visual Studio templates the process was an exercise in patience. SharePoint 2007, on the other hand, makes creating web parts almost easy! This is due to the fact that SharePoint 2007 is based on ASP.NET 2.0 from the ground up, and so native ASP.NET web parts can be deployed to SharePoint.
Note: SharePoint 2003 style web parts are still supported by SharePoint 2007. However, you should consider utilizing ASP.NET 2.0/3.0 web parts both for their better performance and to ensure compatibility with future versions of SharePoint.
Simplified Steps to Create a Web Part
Step 1: Create the server control based on the ASP.NET 2.0.
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Public Class HelloWorld Inherits WebPart Private _text As String <Personalizable()> _ Public Property Text() As String Get Return _text End Get Set(ByVal value As String) _text = value End Set End Property Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter) writer.Write("<h1>HelloWolrld! " & Text & "from" & _ context.User.Identity.Name "</h1>") End Sub
End Class
Note that the above code imports the System.Web.UI.WebControls.WebParts library (i.e. the standard .NET 2.0 class library), rather than the Microsoft.SharePoint library used in SharePoint 2003.
Step 2: Compile to bin folder under SharePoint root folder (if bin folder doesn’t exist you can create it)
Step 3: Edit the SharePoint Web.Config file to include a SafeControls entry for the new web part, specifying the Assembly, Namespace, TypeName of the web part to import. If you want to include all web parts in the specified Assembly and Namespace then you can specify * as a TypeName as I have here:
<SafeControl Assembly="WebPartTest1" Namespace="WebPartTest1" TypeName="*"
Safe="True" />
Step 4: Add the web part to the Web Part Gallery.

Figure 5. Add the web part to the SharePoint web part gallery
Step 5: Place the web part on the page.
If you’ve built a web part for SharePoint 2003 you can see the process has been significantly streamlined! It will not only subtly change the cost/benefit calculation when deciding whether to create a web part from scratch, use a wrapper such as the SmartPart, or simply use the PageViewer web part to display a stand-alone application, but make it easier for novice web part programmers to get started.
Conclusion
In this article you’ve learned about a few of the new features that have made my "top 10" list for SharePoint (my "top 5" to be precise).
While the BDC may not be the answer to all of your data integration woes, Microsoft deserves high marks for making an attempt to provide a common metadata repository and framework for accessing external data sources through SharePoint. The expanded event handling is certain to spawn numerous new uses for SharePoint as commercial vendors and in-house developers merge business logic with document libraries and lists. Windows Workflow Foundation will move your applications development in to an entirely new dimension – that of time – allowing you to create business logic that integrates SharePoint data and documents with sophisticated workflows. The addition of item-level security continues to erode the distinction between SharePoint and traditional document management (DM) systems. Last, but certainly not least, a significantly simplified web part creation and deployment process will save you countless hours and expand the ranks of programmers able to create web part solutions. While these 5 features represent just a tiny fraction of what’s new in SharePoint 2007, taken together they represent a quantum leap in what you can accomplish by building your applications on this platform!
Whether you’re a .NET developer new to SharePoint, or a seasoned SharePoint pro, you’ll definitely want to explore these on your own, as well as look for future articles on these and other SharePoint topics in ASP Today.

