I too am unable to prevent the MoveToTrash event. I'm adding an event handler for canceling publish in the same place (as shown on umbraco tv), and publish does get canceled. Does anyone know if MoveToTrash is a cancelable event?
I figured out that it is in fact canceling the event. It just continues to show the animation in the CMS, so it's confusing. But if you reload the nodes, the one that just dropped off is still there.
It's not only the animation it seems that all children of the node you
cancel programmaticaly doesn't appear anymore in the umbraco.config.
You have to make a publish including all children to get your umbraco.config back to normal. So it really is an issue. Before to make a publish I've also tried a "republish entire site" but it doesn't solve the issue. Moreover after having republished, my children have weird "Link to document" and "Alternative Links" (C.f screenshot)
I'm using a 4.5.1 version, please could you say me if you experiment the same behavior with node children?
I've added a vote to the issue and added my comments.
I'm experiencing the same issue. The content node is not moved to the trash, but unfortunately it is deleted from the cache. My solution is the following:
Once cancelled republish
Then update the document cache to make sure it is republished
Save the sort order programmatically without sorting. This will make sure the document in the cache is not moved to the last position of the deleted documents parents children.
The following is the code I use which seems to solve the issue.
Using Document.BeforeMoveToTrash
I want to stop users deleting certain doctypes. The below event is called correctly. However
e.Cancel = true; doesn't seem to cancel the event. Is this is actually cancelling "MoveToTrashEventArgs"
How do i stop the doc being move to the trash?
public MoveToTrash()
{
Document.BeforeMoveToTrash += new Document.MoveToTrashEventHandler(Document_Trash);
}
static void Document_Trash(Document sender, MoveToTrashEventArgs e)
{
e.Cancel = true;
}
Where are you adding the event handler to the Document class? Chances are it's not wiring up the event
I too am unable to prevent the MoveToTrash event. I'm adding an event handler for canceling publish in the same place (as shown on umbraco tv), and publish does get canceled. Does anyone know if MoveToTrash is a cancelable event?
Is the event handler being run?
It is a cancellable event.
I figured out that it is in fact canceling the event. It just continues to show the animation in the CMS, so it's confusing. But if you reload the nodes, the one that just dropped off is still there.
You could add a bug report to Codeplex here: http://umbraco.codeplex.com/WorkItem/Create.aspx?ProjectName=umbraco
Hello,
It's not only the animation it seems that all children of the node you cancel programmaticaly doesn't appear anymore in the umbraco.config.
You have to make a publish including all children to get your umbraco.config back to normal. So it really is an issue.
Before to make a publish I've also tried a "republish entire site" but it doesn't solve the issue. Moreover after having republished, my children have weird "Link to document" and "Alternative Links" (C.f screenshot)
I'm using a 4.5.1 version, please could you say me if you experiment the same behavior with node children?
I've added a vote to the issue and added my comments.
Regards
And here's the link on codeplex: http://umbraco.codeplex.com/workitem/27048
Hi Guys,
I'm experiencing the same issue. The content node is not moved to the trash, but unfortunately it is deleted from the cache. My solution is the following:
e.Cancel = true;
sender.Publish(new User(0));
umbraco.library.UpdateDocumentCache(sender.Id);
if(sender.ParentId > 0)
{
XmlNode parentNode = content.Instance.XmlContent.GetElementById(sender.ParentId.ToString());
//only try to do the content sort if the the parent node is available...
if (parentNode != null)
content.SortNodes(ref parentNode);
// Load balancing - then refresh entire cache
if (UmbracoSettings.UseDistributedCalls)
library.RefreshContent();
}
I hope it will help you guys and solve any issues you may have too.
Cheers Kim
is working on a reply...