0

First, excuse my english.

I need to control moving some nodes to trash by it's alias. I have created my custom EventHandler for the "Document.BeforeMoveToTrash" event. I can set the Cancel flag to true, for preventing this action.

Is there any way to set error message in event handlers and show it in backend infobubble? I want to show error with some additional error details.

P.S.: Error bubble in my understanding is:

Burgi
  • 421
  • 8
  • 24
Hellaren
  • 422
  • 1
  • 5
  • 15

1 Answers1

1

You can create your own speech bubble, but I don't know if it will be overridden by the before save event.

In a custom userControl or method you would be able to use this code to create your own speech bubble.

var clientTool = new Umbraco.Web.UI.Pages.ClientTools((System.Web.UI.Page)HttpContext.Current.CurrentHandler);
clientTool.ShowSpeechBubble(SpeechBubbleIcon.Error , "Choose first a content page", "Page has not been added.");
dampee
  • 3,392
  • 1
  • 21
  • 37
  • Thanks for answer. Unfortunately it not work for me. In string (System.Web.UI.Page)HttpContext.Current.CurrentHandler throwing "Unable to cast HandlerWrapped to Page" exception. – Hellaren Jan 27 '14 at 04:07
  • and where are you using this code? in a usercontrol, template, ... ? – dampee Jan 29 '14 at 13:05
  • I wrote. I created my custom EventHandler in AppCode – Hellaren Jan 31 '14 at 02:59
  • From which class do you inherit the EventHandler? – dampee Feb 02 '14 at 10:53
  • public class EventHandlers : IApplicationEventHandler. In OnApplicationStarted method I have assigned my control method to event: Document.BeforeMoveToTrash += Documents_BeforeMove; Document.BeforeUnPublish += Documents_BeforeMove; – Hellaren Feb 04 '14 at 05:10
  • You should try to use the "ContentService" events instead of the depricated "Document" objects. – dampee Feb 16 '14 at 17:13
  • Htllo dampee. I'm sorry for not having answered so long. Thanks for answer. I have changed my code in EventHandler for ContentService.UnPublishing event. I tried first method which you proposed (SpeechBubble) but it doesn`t work. Then I tried throw exception in handler, but Umbraco can`t handle this exception and show me yellow screen. What I did wrong? – Hellaren Mar 06 '14 at 03:33
  • Code doesn't seem to work in 7.2 for sure. No matter what variation I try of the speech bubble code an error is thrown about casting the handler as a page / basepage. – Markus Dec 07 '14 at 20:27