Copy Text to Clipboard

What do I need to change?

    protected void cmdGetResearchList_Click(object sender, EventArgs e)
    // Builds the symbol list for nasdaq.com
    {
        string strSymbolName1 = "";
        foreach (GridViewRow row in grdWatchList.Rows)
        {
            strSymbolName1 += row.Cells[2].Text + ",";
        }
        txtResearchList.Text = strSymbolName1;
        Clipboard.SetText(txtResearchList.Text);   // Error here

    }

Compiles but errors.

Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.

What should I change?

Thanks,
DovbermanAsked:
Who is Participating?
 
Paul MacDonaldConnect With a Mentor Director, Information SystemsCommented:
Would it help to just save the text to a file?  I'm not sure you can paste to the clipboard from a web page.
0
 
Paul MacDonaldDirector, Information SystemsCommented:
I'm sorry, but you're trying to paste text to the clipboard from a web page?
0
 
DovbermanAuthor Commented:
I am trying to paste text to the clipboard from my own web page.

This code is in my aspx.cs file.

The string is "UNTD,SAIA,HUBG,STR,ARTNA,NWS,AGM,CBU,VLY,"
0
 
DovbermanAuthor Commented:
There seems to be no resolution. I will copy the text to a popup window.
0
 
DovbermanAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.