New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Copy Text from TextBox to Clipboard


Product Telerik UI for ASP.NET MVC TextBox
Product Version 2024.1.130


How can I copy text from the TextBox component directly within the Clipboard?


To achieve the desired result:

  1. Utilize the TextBox's SuffixOptions() configuration and define a template.
  2. Within the template, create a Button component and wire to its Click event.
  3. Within the event handler, use the Clipboard interface's writeText() method to copy the text from the TextBox.
        .Label(l => l.Content("Email Address").Floating(false))
        .SuffixOptions(suffix => suffix
                .AddComponent(component => component
                    .Events(events => events.Click("onClick"))

        .HtmlAttributes(new { style = "width: 100%;", type = "email" })
        function onClick(e){
            var textBoxValue = $("#email").getKendoTextBox().value();

To see an extended example of the aforementioned approach, refer to the REPL example on copying text from the TextBox within the Clipboard.

More ASP.NET MVC TextBox Resources

See Also

In this article