CopyButton

in namespace DotVVM.BusinessPack.Controls

Renders the HTML button that is able to copy a value to clipboard.

Usage & Scenarios

CopyButton copies a bound value to the clipboard when clicked. Its optional Click command runs only after the copy succeeds.

Sample 1: Copying a reference number

Bind ValueToCopy to the value to copy. Edit the reference, click Copy reference, and paste into the second box to check the result. The counter advances only on a successful copy.

As with the Button, use either Text or inner content for the caption. Here Enabled prevents copying an empty reference.

<label>Reference: <bp:TextBox Text="{value: Reference}" /></label>
<bp:CopyButton Text="Copy reference" ValueToCopy="{value: Reference}"
               Enabled="{value: !string.IsNullOrEmpty(Reference)}"
               Click="{staticCommand: Copies = Copies + 1}" />
<p>Successful copies: {{value: Copies}}</p>
<label>Paste here: <input type="text" /></label>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.CopyButton.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string Reference { get; set; } = "INV-1042";
        public int Copies { get; set; }
    }
}

Properties

Name Type Description Notes Default Value
property icon DisableContentStyle Boolean
attribute
inner element
static value
bindable
default
False
property icon Enabled Boolean Gets or sets a value indicating whether the button is enabled and can be clicked on.
attribute
inner element
static value
bindable
default
True
property icon Text String Gets or sets the text displayed on the button.
attribute
inner element
static value
bindable
default
property icon ValueToCopy Object Gets or sets the value that will be copied to clipboard when the button is clicked. The Click command is triggered after the value is successfully copied.
attribute
inner element
static value
bindable
default
null

Events

Name Type Description
event icon Click Command Gets or sets the command triggered when the button is clicked.

HTML produced by the control