how to implement copy function in asp.net

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default how to implement copy function in asp.net

    I am trying to copy a string in a text box into clipboard and what I did
    was

    Imports System.Windows.Forms

    and


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Button1.Click
    Clipboard.SetDataObject(TextBox1.Text, True)
    End Sub


    but this generates an error saying

    -----------------------------------------------------
    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.
    -----------------------------------------------------

    Any idear what this means?
    Could you help me?

    Thanks in advance.


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    TaeHo Yoo Guest

  2. Similar Questions and Discussions

    1. ListBox Base Class won't let me implement a LoadPostData function
      When I paste in the function declaration code from the VS.NET 2003 IPostBackDataHandler Interface help page and then simply end the function, I...
    2. Word crashes on Copy function
      Running Word 98 on G3 OS9.1. Every time I highlight text to copy or cut word will crash and I have to re-start to get it back up. Can this be...
    3. note 33713 added to function.copy
      this function copyes a file or folder, it needs another function (ls_a): this works perfect. ...
    4. cdrecord copy destroyed another windows copy !!!
      # cdrecord -msinfo dev=1,1,0 RAW/R16 0,221691 # cdrecord -msinfo dev=1,1,0 RAW/R16 44317,51858 what can be implied by those 2 messages ? How...
    5. cdrecord copy destroyed another windows NERO copy for re-writable media
      # cdrecord -msinfo dev=1,1,0 RAW/R16 0,221691 # cdrecord -msinfo dev=1,1,0 RAW/R16 44317,51858 what can be implied by those 2 messages ? How...
  3. #2

    Default Re: how to implement copy function in asp.net

    Hi,

    you should start a new thread and make it use STA. Inside the thread you
    will be able to call the Clipboard function. The problem is that certain
    Windows COM objects require STA and ASP.NET by default is MTA. You also
    could set the ASPCompat Mode to true which means that ASP.NET will work in
    STA mode. But I would recommend it.

    Best regards,

    Marc Höppner
    NeoGeo

    "TaeHo Yoo" <yootaeho@yahoo.com> wrote in message
    news:eiPuPyNUDHA.1664@TK2MSFTNGP11.phx.gbl...
    > I am trying to copy a string in a text box into clipboard and what I did
    > was
    >
    > Imports System.Windows.Forms
    >
    > and
    >
    >
    > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles Button1.Click
    > Clipboard.SetDataObject(TextBox1.Text, True)
    > End Sub
    >
    >
    > but this generates an error saying
    >
    > -----------------------------------------------------
    > 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.
    > -----------------------------------------------------
    >
    > Any idear what this means?
    > Could you help me?
    >
    > Thanks in advance.
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Marc Hoeppner Guest

  4. #3

    Default Re: how to implement copy function in asp.net

    Thanks for your advice.
    Which way would you recommend? and how to set ASPCompat Mode to true?
    If I set ASPCompat Mode to true is there any risks involved?


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    TaeHo Yoo Guest

  5. #4

    Default Re: how to implement copy function in asp.net

    I would recommend using a different thread which is set to STA. Setting the
    whole ASPX process to STA has some other drawbacks, one example being
    greatly reduced performance. If that is not a problem in your scenario, you
    can lookup the <page...> element in MSDN, there is an attribute called
    something like aspcompat that you can set on the Page

    Best regards,

    Marc Höppner
    NeoGeo

    "TaeHo Yoo" <yootaeho@yahoo.com> wrote in message
    news:%23PhSpNXUDHA.1712@TK2MSFTNGP11.phx.gbl...
    > Thanks for your advice.
    > Which way would you recommend? and how to set ASPCompat Mode to true?
    > If I set ASPCompat Mode to true is there any risks involved?
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Marc Hoeppner Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139