Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 649087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:54:16+00:00 2026-05-13T21:54:16+00:00

Using the SharePoint 2010 RC I am having issues canceling the deletion of a

  • 0

Using the SharePoint 2010 RC I am having issues canceling the deletion of a list item using event receivers. My code is firing, setting the cancel property of the SPItemEventProperties, setting an error message, and throwing an error back to the calling thread. This approach works fine in the adding/updating methods, however, when used in the deleting method I can watch the code fire in a debugger, but the item is still moved to the site’s recycling bin.

Further, I am seeing this behavior in a site created from the “CMSPUBLISHINGSITE#2” template from stsadm, but not from a site created from the “Team Site” template via Central Administration.

The misbehaving code follows:

public override void ItemDeleting(SPItemEventProperties properties)
{
    if (!(properties.UserLoginName == "SHAREPOINT\\system"))
    {
        try
        {
            throw new CreatorIdAliasingException("Please contact support if you feel a release web site has been inappropriately assigned to your organization.");
        }
        catch (CreatorIdAliasingException ex)
        {
            properties.Cancel = true;
            properties.ErrorMessage = ex.ToString();
            properties.InvalidateListItem();
            throw;
        }
    }
}

For reference, identical code is contained in the ItemAdding method and works as expected.

public override void ItemAdding(SPItemEventProperties properties)
        {
            base.ItemAdding(properties);
            if (!(properties.UserLoginName == "SHAREPOINT\\system"))
            {
                try
                {
                    throw new InvalidCreatorIdException("Please contact support to add a known URL to your list of release web sites.");
                }
                catch (InvalidCreatorIdException ex)
                {
                    properties.Cancel = true;
                    properties.ErrorMessage = ex.ToString();
                    properties.InvalidateListItem();
                    throw;
                }
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:54:17+00:00Added an answer on May 13, 2026 at 9:54 pm

    I would recommend you to not be using Exceptions as part of your business logic. Exceptions are expensive and should only be used in exceptional cases which are not handled by normal logic.
    Instead, use something like this:

    public override void ItemDeleting(SPItemEventProperties properties)
    {
      if (properties.UserLoginName.ToLower().CompareTo("sharepoint\\system") != 0)
      {
        properties.Cancel = true;
        properties.ErrorMessage = "Some error has occured....";
      }
    }
    

    And, by the way, you are throwing an additional exception within the event handler which probably is the reason that you see this behavior you are experiencing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using SharePoint 2010 Foundation. We have an item in a list that
I'm using SharePoint 2010. I want to create new view for my list. The
I took some code for displaying the content of a sharepoint 2010 list in
I'm having trouble creating a sharepoint project with .net 4.0. Using Visual Studio 2010,
I'm using Sharepoint 2010 and I have a list where I want users to
i'm using Sharepoint 2010 and i want to create a List in a new
I am using SharePoint 2010 and have a customized newform.aspx and editform.aspx that I
I am trying to write a console application in C# using Sharepoint 2010's client
My problem is this one, I am using Sharepoint 2010, I have a form
I am developing the SharePoint Portal in 2010 where i will be using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.