473,385 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to implement copy function in asp.net

I am trying to copy a string in a text box into clipboard and what I did
was

Imports System.Windows.Forms

and
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Clipboard.SetDataObject(TextBox1.Text, True)
End Sub
but this generates an error saying

-----------------------------------------------------
The current thread must set to Single Thread Apartment (STA) mode before
OLE calls can be made. Ensure that your Main function has
STAThreadAttribute marked on it.
-----------------------------------------------------

Any idear what this means?
Could you help me?

Thanks in advance.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #1
3 3912
Hi,

you should start a new thread and make it use STA. Inside the thread you
will be able to call the Clipboard function. The problem is that certain
Windows COM objects require STA and ASP.NET by default is MTA. You also
could set the ASPCompat Mode to true which means that ASP.NET will work in
STA mode. But I would recommend it.

Best regards,

Marc Höppner
NeoGeo

"TaeHo Yoo" <yo******@yahoo.com> wrote in message
news:ei**************@TK2MSFTNGP11.phx.gbl...
I am trying to copy a string in a text box into clipboard and what I did
was

Imports System.Windows.Forms

and
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Clipboard.SetDataObject(TextBox1.Text, True)
End Sub
but this generates an error saying

-----------------------------------------------------
The current thread must set to Single Thread Apartment (STA) mode before
OLE calls can be made. Ensure that your Main function has
STAThreadAttribute marked on it.
-----------------------------------------------------

Any idear what this means?
Could you help me?

Thanks in advance.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #2
Thanks for your advice.
Which way would you recommend? and how to set ASPCompat Mode to true?
If I set ASPCompat Mode to true is there any risks involved?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3
I would recommend using a different thread which is set to STA. Setting the
whole ASPX process to STA has some other drawbacks, one example being
greatly reduced performance. If that is not a problem in your scenario, you
can lookup the <page...> element in MSDN, there is an attribute called
something like aspcompat that you can set on the Page

Best regards,

Marc Höppner
NeoGeo

"TaeHo Yoo" <yo******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks for your advice.
Which way would you recommend? and how to set ASPCompat Mode to true?
If I set ASPCompat Mode to true is there any risks involved?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Oplec | last post by:
Hi, I am learning standard C++ as a hobby. The C++ Programming Language : Special Edition has been the principal source for my information. I read the entirety of the book and concluded that I...
4
by: Peter | last post by:
I want to copy a parent class instance's all datas to a child's. It's actually a C++'s copy constructor. But why the following code does not work - there is a compile error! How it should look...
7
by: Don | last post by:
Can anyone give me an example of implementing ICloneable to give a class I created a "Clone" method so I can make copies of objects. I have no idea where to begin with this. Thanks. - Don
8
by: Gernot Frisch | last post by:
I need this: (basically because I want to read a structure from disk and then fix big/little endian problems for certain members. class ST { int i; float f; double d; };
7
by: Cerebrus99 | last post by:
Hi all, I am confused about how to sort an XML file. I mean how to *actually* sort the data in the physical file, not how to display sorted data. I am using a large XML file as a back-end...
1
by: Jarle Aase | last post by:
Hi, I wrote a multilanguage cms system a few years ago. Different languages are handled by loading php-files where each language-specific string is assigned to a normal php-variable ($LNG...
4
by: shuisheng | last post by:
Dear All, Is there any easy way to make sure all my object copies are deep copy or shallow copy? I do not like to implement it in each class one by one. Thanks, Shuisheng
2
by: ecestd | last post by:
how do you implement a copy constructor for this pointer-based ADT queue #include <cassert // for assert #include <new // for bad_alloc using namespace std; //private:{Queue::Queue(const...
11
by: Bob Altman | last post by:
Hi all, I want to write a generic class that does this: Public Class X (Of T) Public Sub Method(param As T) dim x as T = param >3 End Sub End Class
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.