# Events

You can subscribe to [all Diagram events](https://docs.telerik.com/aspnet-mvc/api/kendo.mvc.ui.fluent/diagrambuilder#eventssystemaction) and then use them to further customize the behavior of the Diagram.

For a complete example on Diagram events, refer to the [demo on using the events of the Diagram](https://demos.telerik.com/aspnet-mvc/diagram/events).

### Handling by Handler Name

The following example demonstrates how to subscribe to events by a handler name.

```Razor HtmlHelper
    @(Html.Kendo().Diagram()
        .Name("diagram")
        .Events(e => e
            .Add("onAdd")
        )
    )
    <script>
        // The Diagram instance is available as an e.sender or this.
        function onAdd(e) {
            // Handle the add event.
        }
    </script>
```

### Handling by Template Delegate

The following example demonstrates how to subscribe to events by a template delegate.

```Razor HtmlHelper
    @(Html.Kendo().Diagram()
        .Name("diagram")
        .Events(e => e
            .Add(@<text>
              function(e) {
                  //Handle the add event inline.
              }
            </text>)
        )
    )
```

## Next Steps

* [Using the Diagram Events (Demo)](https://demos.telerik.com/aspnet-mvc/diagram/events)

## See Also

* [Using the API of the Diagram for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/diagram/api)
* [Diagram Server-Side API for ASP.NET MVC](https://www.telerik.com/aspnet-mvc/documentation/api/diagram)
* [Diagram Client-Side API](https://www.telerik.com/kendo-jquery-ui/documentation/api/dataviz/ui/diagram)
