# Events

The Telerik UI AIPrompt for ASP.NET MVC [exposes multiple events](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/aiprompteventbuilder) like `CommandExecute`, `PromptRequest`, and more, that allow you to control the behavior of the UI component.

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

## Handling by Handler Name

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

```Razor HtmlHelper
    @(Html.Kendo().AIPrompt()
        .Name("aiprompt")
        .Events(ev => ev.PromptRequest("onPromptRequest"))
        ... //Additional configuration
    )
```

```JS scripts
    <script>
        function onPromptRequest(e){
            // Handle the AIPrompt PromptRequest event that triggers when the prompt view 'Generate output' button is clicked.
        }
    </script>
```

## Handling by Template Delegate

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

```Razor HtmlHelper
    @(Html.Kendo().AIPrompt()
        .Name("aiprompt")
        .Events(e => e.PromptRequest(@<text>
            function() {
                // Handle the AIPrompt PromptRequest event inline.
            }
            </text>)
        )
        ... //Additional configuration
    )
```

## Next Steps

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

## See Also

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