W
Wayne Wengert
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(Object data, Boolean copy)
+512
System.Windows.Forms.Clipboard.SetDataObject(Object data) +7
WBA_StaffControls.frmJudgeCommunications.btnCopyToClipboard_Click(Object
sender, EventArgs e) in
c:\inetpub\wwwroot\WBA_StaffControls\frmJudgeCommunications.aspx.vb:312
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
=========================================================
Any thought on how to correct this problem?
Wayne
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(Object data, Boolean copy)
+512
System.Windows.Forms.Clipboard.SetDataObject(Object data) +7
WBA_StaffControls.frmJudgeCommunications.btnCopyToClipboard_Click(Object
sender, EventArgs e) in
c:\inetpub\wwwroot\WBA_StaffControls\frmJudgeCommunications.aspx.vb:312
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
=========================================================
Any thought on how to correct this problem?
Wayne