I have been through a lot of different Stack Overflow questions and answers which are related to this, not to mention tutorial videos, with no success. I need a button which copies a string to my clipboard. The below code is executed successfully when I click the button, but the string isn't copied. Any ideas why?
protected void copyToClipboard()
{
System.Windows.Forms.Clipboard.SetText("String to be copied");
}
protected void Button_Click(object sender, EventArgs e)
{
Thread clipboardThread = new Thread(copyToClipboard);
clipboardThread.SetApartmentState(ApartmentState.STA);
clipboardThread.IsBackground = false;
clipboardThread.Start();
}
Thanks very much!