# Dynamic modules events

The dynamic modules that you created through the module builder also expose events you can subscribe to. This article provides a list of all those events and the data they pass in your event handler arguments.

## IDynamicContentEvent

This interface is implemented by all events which fire for dynamic modules. Use it if you want to subscribe to all of them. Use the following code to subscribe.

```C#
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.DynamicModules.Events;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
       }

       private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
       {
           EventHub.Subscribe<IDynamicContentEvent>(evt => IDynamicContentEventHandler(evt));
       }

       private void IDynamicContentEventHandler(IDynamicContentEvent eventInfo)
       {
           var userId = eventInfo.UserId;
       }
   }
}
```

In the event handler, you can access the ID of the currently logged in user.

## IDynamicContentCreatingEvent

This interface is implemented by all events which fire *before* a dynamic content item is created. There's only one such built-in event, but you should subscribe using the interface rather than the class that implements it. Subscribe using the following code.

```C#
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.DynamicModules.Events;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
       }

       private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
       {
           EventHub.Subscribe<IDynamicContentCreatingEvent>(evt => DynamicContentCreatingEventHandler(evt));
       }

       private void DynamicContentCreatingEventHandler(IDynamicContentCreatingEvent eventInfo)
       {
           var userId = eventInfo.UserId;
           var dynamicContentItem = eventInfo.Item;
       }
   }
}
```

In the event handler you can access the following information:

* The ID of the currently logged in user
* The actual dynamic content item that is going to be created

## IDynamicContentCreatedEvent

This interface is implemented by all events which fire *after* a dynamic content item has been created. There's only one such built-in event, but you should subscribe using the interface rather than the class that implements it. Subscribe using the following code.

```C#
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.DynamicModules.Events;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
       }

       private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
       {
           EventHub.Subscribe<IDynamicContentCreatedEvent>(evt => DynamicContentCreatedEventHandler(evt));
       }

       private void DynamicContentCreatedEventHandler(IDynamicContentCreatedEvent eventInfo)
       {
           var userId = eventInfo.UserId;
           var creationDate = eventInfo.CreationDate;
           var dynamicContentItem = eventInfo.Item;
           var visible = eventInfo.Visible;
       }
   }
}
```

In the event handler you can access the following information:

* The ID of the currently logged in user
* The date when the dynamic content item was created
* The actual dynamic content item that was created
* The Visible property of the dynamic content item.

## IDynamicContentUpdatingEvent

This interface is implemented by all events which fire *before* a dynamic content item is updated. There's only one such built-in event, but you should subscribe using the interface rather than the class that implements it. Subscribe using the following code.

```ASP.NET
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.DynamicModules.Events;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped6;
       }

       private void Bootstrapper_Bootstrapped6(object sender, EventArgs e)
       {
           EventHub.Subscribe<IDynamicContentUpdatingEvent>(evt => DynamicContentUpdatingEventHandler(evt));
       }

       private void DynamicContentUpdatingEventHandler(IDynamicContentUpdatingEvent eventInfo)
       {
           var userId = eventInfo.UserId;
           var dynamicContentItem = eventInfo.Item;
       }
   }
}
```

In the event handler you can access the following information:

* The ID of the currently logged in user
* The actual dynamic content item that is going to be updated

## IDynamicContentUpdatedEvent

This interface is implemented by all events which fire *after* a dynamic content item has been updated. There's only one such built-in event, but you should subscribe using the interface rather than the class that implements it. Subscribe using the following code.

```C#
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.DynamicModules.Events;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped5;
       }

       private void Bootstrapper_Bootstrapped5(object sender, EventArgs e)
       {
           EventHub.Subscribe<IDynamicContentUpdatedEvent>(evt => DynamicContentUpdatedEventHandler(evt));
       }

       private void DynamicContentUpdatedEventHandler(IDynamicContentUpdatedEvent eventInfo)
       {
           var userId = eventInfo.UserId;
           var modificationDate = eventInfo.ModificationDate;
           var dynamicContentItem = eventInfo.Item;
           var visible = eventInfo.Visible;
       }
   }
}
```

In the event handler you can access the following information:

* The ID of the currently logged in user
* The date when the dynamic content item was updated
* The actual dynamic content item that was updated
* The Visible property of the dynamic content item.

## IDynamicContentDeletingEvent

This interface is implemented by all events which fire *before* a dynamic content item is deleted. There's only one such built-in event, but you should subscribe using the interface rather than the class that implements it. Subscribe using the following code.

```C#
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.DynamicModules.Events;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
       }

       private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
       {
           EventHub.Subscribe<IDynamicContentDeletingEvent>(evt => DynamicContentDeletingEventHandler(evt));
       }

       private void DynamicContentDeletingEventHandler(IDynamicContentDeletingEvent eventInfo)
       {
           var userId = eventInfo.UserId;
           var dynamicContentItem = eventInfo.Item;
       }
   }
}
```

In the event handler you can access the following information.

* The ID of the currently logged in user
* The actual dynamic content item that is going to be deleted

## IDynamicContentDeletedEvent

This interface is implemented by all events which fire *after* a dynamic content item has been deleted. There's only one such built-in event, but you should subscribe using the interface rather than the class that implements it. Subscribe using the following code.

```C#
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.DynamicModules.Events;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped4;
       }

       private void Bootstrapper_Bootstrapped4(object sender, EventArgs e)
       {
           EventHub.Subscribe<IDynamicContentDeletedEvent>(evt => DynamicContentDeletedEventHandler(evt));
       }

       private void DynamicContentDeletedEventHandler(IDynamicContentDeletedEvent eventInfo)
       {
           var userId = eventInfo.UserId;
           var deletionDate = eventInfo.DeletionDate;
           var dynamicContentItemId = eventInfo.ItemId;
       }
   }
}
```

In the event handler you can access the following information:

* The ID of the currently logged in user
* The date when the dynamic content item was deleted
* The ID of the dynamic content item that was deleted
