I also have the same issue. I have this event handler that checks whether the media being deleted is use in the content. I wanted to throw a message that it is not possible to delete the media because it is currently being use.
I don't know if anyone still got this issue, but I've made some code that needed this "notificatoin" also, and just needed to refresh the content tree:
var tools = BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.success, "ATENTION !!!", "WE NEED YOU!"); tools.RefreshTree();
ShowSpeechBubble after publishing
Hi,
I've implemented an event handler which runs "AfterPublish". Because I want to send a few e-mails here, I want to notify the users.
When I publish an item, I only see the "Content Published" speech bubble. Other functionality in the event handler works fine.
Please help me :-)
Forgot to mention that I am developing with Umbraco 4.5.2.
I get an error when trying to edit my previous post...
Hi there,
Did you ever find a solution on this? I'm trying to do the exact same thing...
Thanks,
Steve
I've got a feeling that this just doesn't work, from looking at packages like this http://our.umbraco.org/projects/website-utilities/disable-delete
Rich
Pah, pesky thing.
The only way I've managed to get something display is by throwing an exception which then pops up (which is a horrid solution...)
I also have the same issue. I have this event handler that checks whether the media being deleted is use in the content. I wanted to throw a message that it is not possible to delete the media because it is currently being use.
Here's my code.
void Media_BeforeMoveToTrash(Media sender, MoveToTrashEventArgs
e)
{
//This sql get's all the newest versions of the documents which store the DAMP xml and contain the id of the current media item.
string sql = string.Format(
@"
SELECT TOP 1 A.[id] from cmsPropertyData AS A
LEFT JOIN cmsPropertyType AS B ON A.propertytypeid = b.id
where B.dataTypeId IN ('5697','5698','6397','6410','6411','6419','6420','6421')
and A.[dataInt] = '%{0}%' order by A.[id]"
, sender.Id );
using (IRecordsReader
dr = SqlHelper.ExecuteReader(sql))
{
try
{
if
(dr.HasRecords)
{
e.Cancel =
true
;
}
}
catch (Exception
ex)
{
//If the xml can't be converted log it and go to the next row.
Log.Add(LogTypes.Custom, sender.Id, "Error selecting a media " + ex.Message + "-"
+ sender.Text);
}
}
}
@Steven - Can you how you solve it?
It's not really a nice solution but it works for now I am basically some like this:
private void Document_BeforeMoveToTrash(Document sender, MoveToTrashEventArgs e)
{
if (sender.HasChildren)
{
e.Cancel = true;
Log.Add(LogTypes.Save, sender.Id, "This item cannot be deleted because it has children under it");
ShowErrorBubble("Error deleting item",
}
}
private static void ShowErrorBubble(string title, string exception)
{
//todo temp solution as we cannot get the commented code to work (forums suggest it is not possible.)
//we could throw an execption here
throw new Exception("This item cannot be deleted because it has children under it");
//unreachable code below
try
{
umbraco.BasePages.BasePage.Current.ClientTools.ShowSpeechBubble(umbraco.BasePages.BasePage.speechBubbleIcon.info, title, exception);
}
catch (Exception ex)
{
//do nothing at the moment, forums suggest we cannot send an error message
}
}
Alternatively you could just use this line:
Log.Add(LogTypes.Save, sender.Id, "This item cannot be deleted because it has children under it");
This will allow the user to right click on the item and see what happened in the audit history (but it won't display a message to the user)
p.s. Sorry about the formatting the RTE is not playing today
Not possible to use the Logs since i'll be using this on the media section which doesn't have any audit trail as I know. :)
Will try this. Thanks.
I don't know if anyone still got this issue, but I've made some code that needed this "notificatoin" also, and just needed to refresh the content tree:
And that was all that was needed.
Cheers.
is working on a reply...