I'm trying to create a sandboxed event handler feature to handle the OnDeleting event of a task list in SharePoint 2010. I followed Microsoft's instructions. When I deploy the event receiver from Visual Studio, I get an "Attach Security Warning." I select Attach, and the correct SharePoint site opens in the browser.

However, when I navigate to the Tasks list and delete an item, it doesn't tell me "deleting items is not supported" like it should. It just shows the normal delete confirmation message.

Any suggestions about what I might be doing wrong?

Edited to add elements.xml as requested in comments:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="107">

Edited to add EventReceiver1.cs code:

using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace DeletingEventReceiver_TasksTest.EventReceiver1
/// <summary>
/// List Item Events
/// </summary>
public class EventReceiver1 : SPItemEventReceiver
   /// <summary>
   /// An item is being deleted.
   /// </summary>
   public override void ItemDeleting(SPItemEventProperties properties)
       properties.Cancel = true;
       properties.ErrorMessage = "Deleting items from " + properties.RelativeWebUrl + " is not supported.";
  • 1
    SharePoint will always show the normal delete confirmation message. It only after you select OK that OnDeleting is called. Have you tried to go further? Mar 20, 2012 at 16:53
  • What does it do after showing that message? Does it still delete the item? Could you post your Elemenst.xml as well as some details about the list you are testing in? Mar 20, 2012 at 17:34
  • I clicked OK at the confirmation message and the item deleted as normal. The list is the default tasks list that comes with the Team Site template. I've posted the elements.xml contents above.
    – LFurness
    Mar 20, 2012 at 18:54
  • 1
    Can we also see the code for EventReceiver1ItemDeleting? Make sure you don't call the base method at then end as it'll set the status to continue Mar 20, 2012 at 19:11
  • What happens in VisualStudio when you try to set a break point? I assume you are deleting items from the default Tasks list? I had an issue like this quite recently and I honestly think I may have selected the wrong List Type when creating the event receiver and I changed ListTemplateId to ListUrl so I cannot be certain. The next day I started over with a new project and made certain I selected a task list and everything worked. Mar 21, 2012 at 1:41

1 Answer 1


Verify the event receiver is registered

$web = Get-SPWeb "http://site"
$list = $web.Lists["TargetList"]
Write-Host $list.EventReceivers.Count

Also verify if you added safe control entries for the event receiver namespace. See this on how to add safe controls in vs2010. You most likely do not have any safe control entries.

  • Thanks, your PowerShell script showed me that the event receiver was not registered. That led me to realize that I had not deployed the feature correctly as shown here.
    – LFurness
    Mar 21, 2012 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.