This project is read-only.

FileDeleted

Nov 14, 2008 at 10:31 AM
Edited Nov 14, 2008 at 10:56 AM
Hi there,

I need to hook into the FileDeleted event and notify the user that if a file is being used in a ContentItem that they can't delete it. I can hook into the event via FileManager.FileDeleting, but I can't seem to find a way to notify the user, I thought maybe using javascript?

Anyone got any ideas?

Cheers
Nov 14, 2008 at 12:55 PM
Hi,

I think this thread has the info you need?
http://www.codeplex.com/n2/Thread/View.aspx?ThreadId=32989
Nov 14, 2008 at 2:58 PM
Hi Martijn,

thanks for that pointer.

I didn't explain myself very well!

I have created an interceptor that subscribes to the event that I need. What I cannot do is notify the user that they can't delete a file.

Any idea on how to notify the user that they cannot delete a file, when I have caught and handled the FileDeleting event?

Cheers
Nov 14, 2008 at 5:13 PM
I use this in one of my projects in the OnItemSaving method

        if (item.Parent != null)
            if (item.Parent.Name == "Trash")
            {
                if (item.GetType() == typeof(PageItemTop) ||
                    item.GetType() == typeof(PageItemAdmin) ||
                    item.GetType() == typeof(PageItemHome)
                    )
                {
                    e.Cancel = true;
                    HttpContext.Current.Response.Redirect("~/Secured/delete_not_allowed.aspx");
                }
            }

Looks strange, but that does catch a delete (which is saving to the trash) an shows a page to the user.
Nov 15, 2008 at 6:04 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.