473,804 Members | 3,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy To Clipboard Problem

I have an aspx page on which I am trying to copy the contents of a textbox
to the client clipboard when the users clicks a button. The button code is
as follows:
=============== =============== =======
Private Sub btnCopyToClipbo ard_Click(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles btnCopyToClipbo ard.Click

Clipboard.SetDa taObject(txtHid den.Text)

End Sub

=============== =============== =============== ====

When the button is clicked, I am getting the following error pointing to the
statement in the above sub.

=============== =============== =============== =====

Exception Details: System.Threadin g.ThreadStateEx ception: The current thread
must set to Single Thread Apartment (STA) mode before OLE calls can be made.
Ensure that your Main function has STAThreadAttrib ute marked on it.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[ThreadStateExce ption: The current thread must set to Single Thread
Apartment (STA) mode before OLE calls can be made. Ensure that your Main
function has STAThreadAttrib ute marked on it.]
System.Windows. Forms.Clipboard .SetDataObject( Object data, Boolean copy)
+512
System.Windows. Forms.Clipboard .SetDataObject( Object data) +7
WBA_StaffContro ls.frmJudgeComm unications.btnC opyToClipboard_ Click(Object
sender, EventArgs e) in
c:\inetpub\wwwr oot\WBA_StaffCo ntrols\frmJudge Communications. aspx.vb:312
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292
=============== =============== =============== ============

Any thought on how to correct this problem?

Wayne
Nov 19 '05 #1
4 9196
Wayne,

Client clipboard is located on the client machine. Your code tries to set
your web server's clipboard. On client side you can use javascript
window.clipboar dData object.

Eliyahu

"Wayne Wengert" <wa***********@ wengert.org> wrote in message
news:ux******** ******@TK2MSFTN GP09.phx.gbl...
I have an aspx page on which I am trying to copy the contents of a textbox
to the client clipboard when the users clicks a button. The button code is
as follows:
=============== =============== =======
Private Sub btnCopyToClipbo ard_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnCopyToClipbo ard.Click

Clipboard.SetDa taObject(txtHid den.Text)

End Sub

=============== =============== =============== ====

When the button is clicked, I am getting the following error pointing to the statement in the above sub.

=============== =============== =============== =====

Exception Details: System.Threadin g.ThreadStateEx ception: The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttrib ute marked on it.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[ThreadStateExce ption: The current thread must set to Single Thread
Apartment (STA) mode before OLE calls can be made. Ensure that your Main
function has STAThreadAttrib ute marked on it.]
System.Windows. Forms.Clipboard .SetDataObject( Object data, Boolean copy)
+512
System.Windows. Forms.Clipboard .SetDataObject( Object data) +7
WBA_StaffContro ls.frmJudgeComm unications.btnC opyToClipboard_ Click(Object sender, EventArgs e) in
c:\inetpub\wwwr oot\WBA_StaffCo ntrols\frmJudge Communications. aspx.vb:312
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +1292
=============== =============== =============== ============

Any thought on how to correct this problem?

Wayne

Nov 19 '05 #2
Thanks for the quick response. Do you have a pointer to any exanples of how
to do this?

Wayne

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:Ox******** ******@TK2MSFTN GP09.phx.gbl...
Wayne,

Client clipboard is located on the client machine. Your code tries to set
your web server's clipboard. On client side you can use javascript
window.clipboar dData object.

Eliyahu

"Wayne Wengert" <wa***********@ wengert.org> wrote in message
news:ux******** ******@TK2MSFTN GP09.phx.gbl...
I have an aspx page on which I am trying to copy the contents of a
textbox
to the client clipboard when the users clicks a button. The button code
is
as follows:
=============== =============== =======
Private Sub btnCopyToClipbo ard_Click(ByVal sender As System.Object, ByVal

e
As System.EventArg s) Handles btnCopyToClipbo ard.Click

Clipboard.SetDa taObject(txtHid den.Text)

End Sub

=============== =============== =============== ====

When the button is clicked, I am getting the following error pointing to

the
statement in the above sub.

=============== =============== =============== =====

Exception Details: System.Threadin g.ThreadStateEx ception: The current

thread
must set to Single Thread Apartment (STA) mode before OLE calls can be

made.
Ensure that your Main function has STAThreadAttrib ute marked on it.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[ThreadStateExce ption: The current thread must set to Single Thread
Apartment (STA) mode before OLE calls can be made. Ensure that your Main
function has STAThreadAttrib ute marked on it.]
System.Windows. Forms.Clipboard .SetDataObject( Object data, Boolean
copy)
+512
System.Windows. Forms.Clipboard .SetDataObject( Object data) +7

WBA_StaffContro ls.frmJudgeComm unications.btnC opyToClipboard_ Click(Object
sender, EventArgs e) in
c:\inetpub\wwwr oot\WBA_StaffCo ntrols\frmJudge Communications. aspx.vb:312
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o
stBackEvent(Str ing
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
+33
System.Web.UI.P age.ProcessRequ estMain() +1292
=============== =============== =============== ============

Any thought on how to correct this problem?

Wayne


Nov 19 '05 #3
If you have MSDN library installed, just find "clipboardD ata" in the index.
Alternatively go to
http://msdn.microsoft.com/library/de...pboardData.asp

You will find an example there.

Eliyahu

"Wayne Wengert" <wa***********@ wengert.org> wrote in message
news:OH******** ******@tk2msftn gp13.phx.gbl...
Thanks for the quick response. Do you have a pointer to any exanples of how to do this?

Wayne

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:Ox******** ******@TK2MSFTN GP09.phx.gbl...
Wayne,

Client clipboard is located on the client machine. Your code tries to set your web server's clipboard. On client side you can use javascript
window.clipboar dData object.

Eliyahu

"Wayne Wengert" <wa***********@ wengert.org> wrote in message
news:ux******** ******@TK2MSFTN GP09.phx.gbl...
I have an aspx page on which I am trying to copy the contents of a
textbox
to the client clipboard when the users clicks a button. The button code
is
as follows:
=============== =============== =======
Private Sub btnCopyToClipbo ard_Click(ByVal sender As System.Object, ByVal
e
As System.EventArg s) Handles btnCopyToClipbo ard.Click

Clipboard.SetDa taObject(txtHid den.Text)

End Sub

=============== =============== =============== ====

When the button is clicked, I am getting the following error pointing
to the
statement in the above sub.

=============== =============== =============== =====

Exception Details: System.Threadin g.ThreadStateEx ception: The current

thread
must set to Single Thread Apartment (STA) mode before OLE calls can be

made.
Ensure that your Main function has STAThreadAttrib ute marked on it.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[ThreadStateExce ption: The current thread must set to Single Thread
Apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttrib ute marked on it.]
System.Windows. Forms.Clipboard .SetDataObject( Object data, Boolean
copy)
+512
System.Windows. Forms.Clipboard .SetDataObject( Object data) +7

WBA_StaffContro ls.frmJudgeComm unications.btnC opyToClipboard_ Click(Object
sender, EventArgs e) in
c:\inetpub\wwwr oot\WBA_StaffCo ntrols\frmJudge Communications. aspx.vb:312
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o stBackEvent(Str ing
eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
+33
System.Web.UI.P age.ProcessRequ estMain() +1292
=============== =============== =============== ============

Any thought on how to correct this problem?

Wayne



Nov 19 '05 #4
Thank you. I'll use that link and see if I can get this working.

Wayne

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:el******** ******@TK2MSFTN GP14.phx.gbl...
If you have MSDN library installed, just find "clipboardD ata" in the
index.
Alternatively go to
http://msdn.microsoft.com/library/de...pboardData.asp

You will find an example there.

Eliyahu

"Wayne Wengert" <wa***********@ wengert.org> wrote in message
news:OH******** ******@tk2msftn gp13.phx.gbl...
Thanks for the quick response. Do you have a pointer to any exanples of

how
to do this?

Wayne

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:Ox******** ******@TK2MSFTN GP09.phx.gbl...
> Wayne,
>
> Client clipboard is located on the client machine. Your code tries to set > your web server's clipboard. On client side you can use javascript
> window.clipboar dData object.
>
> Eliyahu
>
> "Wayne Wengert" <wa***********@ wengert.org> wrote in message
> news:ux******** ******@TK2MSFTN GP09.phx.gbl...
>> I have an aspx page on which I am trying to copy the contents of a
>> textbox
>> to the client clipboard when the users clicks a button. The button
>> code
>> is
>> as follows:
>> =============== =============== =======
>> Private Sub btnCopyToClipbo ard_Click(ByVal sender As System.Object, ByVal > e
>> As System.EventArg s) Handles btnCopyToClipbo ard.Click
>>
>> Clipboard.SetDa taObject(txtHid den.Text)
>>
>> End Sub
>>
>> =============== =============== =============== ====
>>
>> When the button is clicked, I am getting the following error pointing to > the
>> statement in the above sub.
>>
>> =============== =============== =============== =====
>>
>> Exception Details: System.Threadin g.ThreadStateEx ception: The current
> thread
>> must set to Single Thread Apartment (STA) mode before OLE calls can be
> made.
>> Ensure that your Main function has STAThreadAttrib ute marked on it.
>>
>> Source Error:
>>
>> An unhandled exception was generated during the execution of the
>> current web request. Information regarding the origin and location of the >> exception can be identified using the exception stack trace below.
>>
>> Stack Trace:
>>
>> [ThreadStateExce ption: The current thread must set to Single Thread
>> Apartment (STA) mode before OLE calls can be made. Ensure that your Main >> function has STAThreadAttrib ute marked on it.]
>> System.Windows. Forms.Clipboard .SetDataObject( Object data, Boolean
>> copy)
>> +512
>> System.Windows. Forms.Clipboard .SetDataObject( Object data) +7
>>
> WBA_StaffContro ls.frmJudgeComm unications.btnC opyToClipboard_ Click(Object
>> sender, EventArgs e) in
>> c:\inetpub\wwwr oot\WBA_StaffCo ntrols\frmJudge Communications. aspx.vb:312
>> System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
>>
> System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP o > stBackEvent(Str ing
>> eventArgument) +57
>> System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
>> sourceControl, String eventArgument) +18
>> System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
>> +33
>> System.Web.UI.P age.ProcessRequ estMain() +1292
>>
>>
>> =============== =============== =============== ============
>>
>>
>>
>> Any thought on how to correct this problem?
>>
>>
>>
>> Wayne
>>
>>
>
>



Nov 19 '05 #5

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

Similar topics

11
2224
by: Danny J. Lesandrini | last post by:
Has anyone else noticed this? I searched group archives and found nothing, but it's really starting to irritate me big time. Here's the steps to reproduce the problem: Copy something to the clipboard (eg code from a web page) Open Microsoft Access MDB file Open any module Press Ctl-V to insert text Voilia, the text is gone. Opening access dumps the copy buffer.
2
3267
by: Shayne H | last post by:
I am trying to write a method to copy some text to the clipboard, and leave a copy of it there after the application has exited. Sub CopyToClipboard(ByVal value As Object) Dim data As New DataObject() data.SetData(DataFormats.UnicodeText, True, value) Clipboard.SetDataObject(data,True) End Sub When I test it, I get an exception:
5
21040
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in windows explorer: when you do a right-click on a file and choose Copy, and than paste it somewhere in my application and vice versa.
2
2689
by: Keith | last post by:
I'm trying to come up with a way to create a contextmenu that will do all the "standard" functions (cut, copy, paste, undo, etc). There seems to be a lot of information out there - but nothing seems to work for me. A few people refer to txt.copy() txt.paste(), etc. I'm not sure if those are old functions, but they do not work for me. I've tried textbox1.selectall() - that works in selecting
7
11645
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
0
2670
by: mhospodarsky | last post by:
Hi-- I am using VB.Net 2002 for this app. I am working with Tiff and jpeg images. I have a picturebox set up that I use to view the images. I have the picture box inside of a scrollable panel.There are two viewing preferences available: to view the image with scrollbars (the original image unsized), and to view the iamge without scrollbars (the image resized to fit within the panel's viewing range.) When I resize the image so that...
8
2619
by: serge calderara | last post by:
Dear all, I have an treeview control with different node object, I would like to implement the Copy/Paste function of an object . For that I am using the folowing function to copy teh object to clipboard : ====> Private Sub CopyToClipboard(ByVal Obj As PluginApp.PlugInReport) ' Creates a new data format.
9
4821
by: Alan T | last post by:
Any source code example I can use to save the clipboard content to an object, then I will do a copy and paste, finally put back the 'saved' clipboard content back to clipboard ?
17
5139
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have about 20 textboxes on the form). Also to ensure that the button can't get used if the cursor isn't in a textbox field. And to ensure the contents of the clipboard are "text" contents that have been cut/copied from one of the textboxes on the form. ...
0
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.