VS experts

Imoe

Senior Member
Joined
Apr 5, 2009
Messages
554
To all the VS experts. I am using vb to code. I have an aspx webform with a textbox and a button. I need to copy the text within the textbox to the clipboard using the button. I have tried using clipboard.settext() however I get the following error

"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"

I do not want to use HTML.

I have googled for the last five days and have not found a solution. I am now running quickly out of time.

Any Suggestions please?
 
Last edited:

davemc

Executive Member
Joined
Apr 8, 2009
Messages
6,518
Iome, you're asking the multi-threaded web server to copy the text into the server's clipboard, that's why you're getting that error.

You will have to attach a javascript program to the webform and that javascript program will run on the client and it may be possible to overwrite the clipboard contents from javascript, depending on the platform rules that the javascript is running under on the client.

Is there not a better solution, e.g. providing a link to download whatever it is they're copying to the clipboard?
 

Roo!

Expert Member
Joined
Sep 28, 2006
Messages
1,142
Here's a link to the required javaScript code. BTW this code will only work in IE, which sucks.
 
Last edited:
Top