We can Set/Get/Clear users’ clipboard by the JavaScript window.clipboardData object, which only works in Internet Explorer, by the following code:
window.clipboardData.setData("text",value)
window.clipboardData.getData("text")
window.clipboardData.clearData("text")
If you need set a code-behind value to user’s clipboard, please pass it to JavaScript variable first, and then, set the value to clipboard. Or you can call the JavaScript from code-behind, just like the following code:
protected
void
Button1_Click(
object
sender, EventArgs e)
{
string values = " hello world " ;
ClientScript.RegisterStartupScript( this .GetType(), " copy " , " window.clipboardData.setData('text',' " + values + " ') " , true );
}
{
string values = " hello world " ;
ClientScript.RegisterStartupScript( this .GetType(), " copy " , " window.clipboardData.setData('text',' " + values + " ') " , true );
}
Thanks.