2
    public override void ItemDeleting(SPItemEventProperties properties)
    {
        try
        {
            properties.Status = SPEventReceiverStatus.CancelWithError;
            properties.ErrorMessage = SPUtility.GetLocalizedString("$Resources:MyResources,ER_DeletionError", "MyResources", properties.Web.Language);
        }
        finally
        {
            //_currentContext.Response.Redirect(properties.WebUrl, true);
        }
    }

Now it works fine, it doesn't deletes the item, but when i click on "OK" for error message, item disappears from screen and comes back only when i refresh the page, any clues ?

Edit

It only happens when your list is opened in "Edit in Datasheet" view, otherwise it takes you to another window with error.

1
  • I'm almost sure it has something to do with the Datasheet view javascript implementation. I'm just guessing, but I think the client-side delete event handler fires first (and evidently hides/removes the element from the DOM). Later, when the server replies with the Cancel status, the element is already gone from the view, though still present in the db, and that's why you have to refresh the page to see it back again
    – MdMazzotti
    Commented May 14, 2015 at 17:36

1 Answer 1

0

Not a solution for everyone but I used jslink to add a post render method for this custom list, in post render method I am refreshing page after click event on delete error message box.

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.