473,221 Members | 1,649 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,221 software developers and data experts.

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 btnCopyToClipboard_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnCopyToClipboard.Click

Clipboard.SetDataObject(txtHidden.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.Threading.ThreadStateException: 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.

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:

[ThreadStateException: 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.]
System.Windows.Forms.Clipboard.SetDataObject(Objec t data, Boolean copy)
+512
System.Windows.Forms.Clipboard.SetDataObject(Objec t data) +7
WBA_StaffControls.frmJudgeCommunications.btnCopyTo Clipboard_Click(Object
sender, EventArgs e) in
c:\inetpub\wwwroot\WBA_StaffControls\frmJudgeCommu nications.aspx.vb:312
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
================================================== =======

Any thought on how to correct this problem?

Wayne
Nov 19 '05 #1
4 9160
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.clipboardData object.

Eliyahu

"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:ux**************@TK2MSFTNGP09.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 btnCopyToClipboard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopyToClipboard.Click

Clipboard.SetDataObject(txtHidden.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.Threading.ThreadStateException: 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.

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:

[ThreadStateException: 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.]
System.Windows.Forms.Clipboard.SetDataObject(Objec t data, Boolean copy)
+512
System.Windows.Forms.Clipboard.SetDataObject(Objec t data) +7
WBA_StaffControls.frmJudgeCommunications.btnCopyTo Clipboard_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\WBA_StaffControls\frmJudgeCommu nications.aspx.vb:312
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePo
stBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +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.com> wrote in message
news:Ox**************@TK2MSFTNGP09.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.clipboardData object.

Eliyahu

"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:ux**************@TK2MSFTNGP09.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 btnCopyToClipboard_Click(ByVal sender As System.Object, ByVal

e
As System.EventArgs) Handles btnCopyToClipboard.Click

Clipboard.SetDataObject(txtHidden.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.Threading.ThreadStateException: 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.

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:

[ThreadStateException: 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.]
System.Windows.Forms.Clipboard.SetDataObject(Objec t data, Boolean
copy)
+512
System.Windows.Forms.Clipboard.SetDataObject(Objec t data) +7

WBA_StaffControls.frmJudgeCommunications.btnCopyTo Clipboard_Click(Object
sender, EventArgs e) in
c:\inetpub\wwwroot\WBA_StaffControls\frmJudgeCommu nications.aspx.vb:312
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePo
stBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
================================================== =======

Any thought on how to correct this problem?

Wayne


Nov 19 '05 #3
If you have MSDN library installed, just find "clipboardData" 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**************@tk2msftngp13.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.com> wrote in message
news:Ox**************@TK2MSFTNGP09.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.clipboardData object.

Eliyahu

"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:ux**************@TK2MSFTNGP09.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 btnCopyToClipboard_Click(ByVal sender As System.Object, ByVal
e
As System.EventArgs) Handles btnCopyToClipboard.Click

Clipboard.SetDataObject(txtHidden.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.Threading.ThreadStateException: 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.

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:

[ThreadStateException: 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.]
System.Windows.Forms.Clipboard.SetDataObject(Objec t data, Boolean
copy)
+512
System.Windows.Forms.Clipboard.SetDataObject(Objec t data) +7

WBA_StaffControls.frmJudgeCommunications.btnCopyTo Clipboard_Click(Object
sender, EventArgs e) in
c:\inetpub\wwwroot\WBA_StaffControls\frmJudgeCommu nications.aspx.vb:312
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePo stBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +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.com> wrote in message
news:el**************@TK2MSFTNGP14.phx.gbl...
If you have MSDN library installed, just find "clipboardData" 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**************@tk2msftngp13.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.com> wrote in message
news:Ox**************@TK2MSFTNGP09.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.clipboardData object.
>
> Eliyahu
>
> "Wayne Wengert" <wa***********@wengert.org> wrote in message
> news:ux**************@TK2MSFTNGP09.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 btnCopyToClipboard_Click(ByVal sender As System.Object, ByVal > e
>> As System.EventArgs) Handles btnCopyToClipboard.Click
>>
>> Clipboard.SetDataObject(txtHidden.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.Threading.ThreadStateException: 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.
>>
>> 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:
>>
>> [ThreadStateException: 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.]
>> System.Windows.Forms.Clipboard.SetDataObject(Objec t data, Boolean
>> copy)
>> +512
>> System.Windows.Forms.Clipboard.SetDataObject(Objec t data) +7
>>
> WBA_StaffControls.frmJudgeCommunications.btnCopyTo Clipboard_Click(Object
>> sender, EventArgs e) in
>> c:\inetpub\wwwroot\WBA_StaffControls\frmJudgeCommu nications.aspx.vb:312
>> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
>>
> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePo > stBackEvent(String
>> eventArgument) +57
>> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
>> sourceControl, String eventArgument) +18
>> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
>> +33
>> System.Web.UI.Page.ProcessRequestMain() +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
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...
2
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...
5
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...
2
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...
7
by: lgbjr | last post by:
Hello All, Im 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...
0
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...
8
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...
9
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
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

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.