# Events

The Telerik UI Chat for ASP.NET Core exposes multiple [events](https://www.telerik.com/aspnet-core-ui/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>
```

```Razor TagHelper
<kendo-chat name="chat"
    on-send-message="onSendMessage"
    on-suggestion-click="onSuggestionClick">
</kendo-chat>

<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>)
    )
)
```

```Razor TagHelper
<kendo-chat name="chat"
    on-send-message="function() {
        // Handle the SendMessage event inline.
    }">
</kendo-chat>
```

## See Also

* [Using the API of the Chat for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/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-core-ui/documentation/api/chat)

* [Server-Side API of the Chat TagHelper](https://www.telerik.com/aspnet-core-ui/documentation/api/taghelpers/chat)
