Reputation: 25
I am trying to get a copy to clipboard in my .ascx file. Since this is ASP.NET, there is no main function to put [STAThread] on.
I am getting an error stating: "Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it."
In my ascx.cs file I have using System.Windows.Forms;
and then one line of code Clipboard.SetText("Hello, clipboard");
I've attempted to find a solution, but most solutions assume that there is a main, or say to delete dlls. These solutions are not fit for my situation.
Upvotes: 0
Views: 955
Reputation: 32694
You are following the wrong approach. You're thinking about this from a server side perspective, but you can't access a user's clipboard from the server side. You can however do it from JavaScript running on the client. But that's a different question, and it's already been answered.
Upvotes: 2