# Events

The Telerik UI Chat for ASP.NET MVC exposes multiple [events](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/chateventbuilder) that allow you to control and customize the behavior of the component.

## Handling by Handler Name

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

```Razor HtmlHelper
@(Html.Kendo().Chat()
    .Name("chat")
    .Events(e => e
        .SendMessage("onSendMessage")
        .SuggestionClick("onSuggestionClick")
    )
)
<script>
    function onSendMessage() {
        // Handle the "SendMessage" event.
    }

    function onSuggestionClick() {
        // Handle the "SuggestionClick" event.
    }
</script>
```

## Handling by Template Delegate

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

```Razor HtmlHelper
@(Html.Kendo().Chat()
    .Name("chat")
    .Events(e => e
        .SendMessage(@<text>
            function() {
                // Handle the SendMessage event inline.
            }
        </text>)
    )
)
```

## See Also

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