470,631 Members | 1,621 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

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 9039
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Danny J. Lesandrini | last post: by
2 posts views Thread by Keith | last post: by
7 posts views Thread by lgbjr | last post: by
reply views Thread by mhospodarsky | last post: by
8 posts views Thread by serge calderara | last post: by
9 posts views Thread by Alan T | last post: by
17 posts views Thread by Steve | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.