Skip to content

Latest commit

 

History

History
32 lines (20 loc) · 2.19 KB

index.md

File metadata and controls

32 lines (20 loc) · 2.19 KB

Using events

Umbraco uses .Net events to allow you to hook into the workflow processes for the backoffice. For example you might want to execute some code every time a page is published. Events allow you to do that.

Umbraco allows you to execute code during application startup. This is also the correct place to register for many other types of events including the ability to bind to HttpApplication events.

Events

Typically, the events available exist in pairs, with a "before" and "after" event. For example the ContentService class has the concept of publishing, and fires events when this occurs. In that case there is both a ContentService.Publishing and ContentService.Published event.

Which one you want to use depends on what you want to achieve. If you want to be able to cancel the action, then you would use the "before" event, and use the eventargs to cancel it. See the sample handler further down. If you want to execute some code after the publishing has succeeded, then you would use the "after" event.

Content and Media events

Other events

Tree events

Editor Model events

See EditorModelEventManager Events for a listing of the EditorModel events (hint: useful for manipulating the model before it is sent to an editor in the backoffice - eg. perhaps to set a default value of a property on a new document)