The Blazor SmartPasteButton fills a form from whatever text is in the clipboard - an email, a signature, a document - by asking an AI model to extract the fields of the form model.
1. Copy some text with customer details
Console log
Set Data to the form model. On click the button reads the clipboard, describes the public properties of the model (name, type, and any [Description] or [Display] attribute)
to the IChatClient configured for IAIChatService, asks for a JSON object with those keys and assigns the values, converting dates, numbers, booleans and enums.
Properties the text does not mention stay unchanged. Use Fields to restrict which properties are filled, Instructions to add rules such as the expected language,
and Pasted to react when the model is filled. Call Paste(text) to fill the model from a string instead of the clipboard.
Reading the clipboard requires a user gesture and, in most browsers, the user's permission; the EmptyClipboard event fires when nothing could be read.
It reads the clipboard, describes the properties of the form model to the AI model, asks for a JSON object with those keys and assigns the converted values.
Strings, numbers, booleans, dates (DateTime, DateOnly, TimeOnly, DateTimeOffset), enums and Guids, including their nullable variants.
Radzen Blazor Components, © 2018-2026 Radzen.
Source Code licensed under
MIT
On this page