Event Registrations

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Register event handlers at the site or site collection level that you will use to implement filtering to respond to list item events.

The Receivers element specifies an event handler for list item events.











To register an event handler for list events, create a folder in \Template\Features to contain a Feature.xml file that specifies the scope and ID of the Feature, and an elements manifest file that the former file references.

The Feature.xml file that registers an event handler might look like the following.

  Title="Simple Updating Item Event Handler Registration" 
    <ElementManifest Location="elements.xml"/>

The elements manifest file registers the event handler assembly and associates it with a list type, which the following example specifies to be announcement lists (104).

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Assembly>SimpleUpdateEventHandler, Version=, Culture=neutral, PublicKeyToken=10b23036c9b36d6d</Assembly>

The .cs file for the event handler can use the Windows SharePoint Services object model to respond to events. For information about using the object model to create custom event handlers, see Event Fundamentals.

The following example defines the content of an error message to display when users attempt to modify items in a list.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace MS.Samples
    public class SimpleItemUpdateHandler : SPItemEventReceiver
        public override void ItemUpdating(SPItemEventProperties properties)
            properties.Cancel = true;
            properties.ErrorMessage = "Updating data is not supported.";

See Also


How to: Create an Event Handler Feature

Other Resources

Event Fundamentals