I'm trying to Show a Warning Message when deleting a content page from backoffice
I tried this "it is working on Umbraco 7 but not on Umbraco 8.1.1"
private void ContentService_Trashing(IContentService sender, MoveEventArgs<IContent> e)
{
///inform the user if the post is favorate
try
{
foreach (var content in e.MoveInfoCollection
//Check if the content item type has a specific alias
.Where(c => c.Entity.ContentType.Alias.InvariantEquals(Helper.PostContentTypeAlias))
//Check if it is a new item
//.Where(c => c.HasIdentity == false)
)
{
//check if the item has a property called 'richText'
if (DB_Oprs.DB_Oprs.IfFavoratePost(content.Entity.Id))
{
e.Messages.Add(new EventMessage("Warning", string.Format("Can not delete {0}", " This Post Is Favorate"), EventMessageType.Warning));
}
}
}
catch (Exception ex)
{
Current.Logger.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, ex.Message, ex);
}
}
No - I don't think that is possible because notification is delivered to the page and in this case page gets removed so they have no holding area to show message.
A hacky version that would work but would not be optimal is to create a JavaScript properly editor, put this on the document type and use the “onFormSubmitting”-event to trigger a notification in the notificationService.
This would allow the item to be saved while the notification is shown. The drawback is that you would need a property on the document type only to show the notification.
Notification Message when delete content
Hi,
I'm trying to Show a Warning Message when deleting a content page from backoffice
I tried this "it is working on Umbraco 7 but not on Umbraco 8.1.1"
I Appreciate Any Help.
Hi
Message will only appear when we cancel the event. It can be done using this command.
You can add it just after the e.Messages and as Node is not removed so message will appear.
Please check and let me know your views.
Ok, That worked fine ... but I don't want to cancel the operation I just want to show a piece of information about the content.
is that possible?
No - I don't think that is possible because notification is delivered to the page and in this case page gets removed so they have no holding area to show message.
Hope that helps.
What about the notification area where Umbraco shows a message to say the page has been deleted?
If I wanted to show an additional message, how would I do this? (not preventing the deletion)
A hacky version that would work but would not be optimal is to create a JavaScript properly editor, put this on the document type and use the “onFormSubmitting”-event to trigger a notification in the notificationService.
This would allow the item to be saved while the notification is shown. The drawback is that you would need a property on the document type only to show the notification.
is working on a reply...