Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • TikTakToe 60 posts 102 karma points
    Jun 23, 2015 @ 14:52
    TikTakToe
    0

    ContentService.Deleted e.Cancel = true throws error

    I'm adding in a check to prevent the deletion of certain items:

           private void Content_Deleted(IContentService sender, DeleteEventArgs<IContent> e)
            {
                if (e.DeletedEntities.Any(node => tagsToCheck.Contains(node.Id)))
                {
                    e.Cancel = true;
                }
             }
    

    but this throws and error: This event argument class does not support cancelling

    Any ideas?

    For now I'm throwing an error to cancel and show in the dashboard, but would like a more elegant solution!

    Also, while we're there, how do i show a friendly error page in the dashboard?

    thanks in advance

    Ian

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Jun 23, 2015 @ 17:35
    Marcel van Helmont
    0

    Hello TikTakToe,

    You need to hookup the event deleting. With the delete event the node is already deleted. With the deleting event it's right before he delete the node.

    Marcel

  • TikTakToe 60 posts 102 karma points
    Jun 23, 2015 @ 21:27
    TikTakToe
    0

    Thanks Marcel - on further investigation (helped by your tip), i was using the wrong event anyway - I needed the ContentService.Trashing event which fires when you 'delete' a node (which doesn't really delete but moves it to the recycle bin!)

Please Sign in or register to post replies

Write your reply to:

Draft