Copy text from listbox to clipboard RRS feed

  • Question

  • User-1436987328 posted


    My web page displays a list box which is populated from a sql server database. The user wants to be able to click a button which copies part of the data in the list box.

    I found lots of examples which do not really do what I want or do not work.

    Any ideas?



    Wednesday, June 15, 2011 4:10 PM


All replies

  • User-1188032534 posted

    Copy to clipboard is often blocked by the webbrowser due to privacy and security reasons. There's is no reliable way to automatically set a users clipboard data from a web page.


    Wednesday, June 15, 2011 4:20 PM
  • User-668204308 posted

    I'm actually having a similar problem. I need to get a variable in the clipboard with VB code too. I've seen tons of javascript code with something like html buttons calling it but that's not what we need. If you find a way to do what you want please post here, I'll be searching for a solution too like I've been doing for the past 1,5 hours.

    Tuesday, June 21, 2011 7:13 AM
  • User-668204308 posted

    I found something neet. The information I needed was displayed in a messagebox, and I just found out that with Control + C we can get everything from the text box, so that solved my problem as I simply told the user to Control + C if he needed this info.
    Reference: http://secretgeek.net/msgbox_copy.asp

    Tuesday, June 21, 2011 10:02 AM
  • User-1436987328 posted

    I need to be able to copy some text from a listbox. control +C will not work for me. The listbox is made up of several columns of data read from a sql database. the user wants to be able to copy and paste a portion of that data. I simply want to be able to code a button which when clicked, copies some of the data. i found idataobject which can copy data to a clipoboard but this is only available in system.windows.forms and is not allowed to be imported into a web based application.

    Tuesday, June 21, 2011 11:34 AM
  • User-668204308 posted

    I've seen javascript code that takes text from a textbox and takes it to the clipboard. Maybe you could create an invisible textbox or label that recieves the data the user needs and then the button could retrieve it from it's text property?
    Here's a javascript code reference: http://www.geekpedia.com/tutorial126_Clipboard-cut-copy-and-paste-with-JavaScript.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 22, 2011 4:15 AM
  • User-1188032534 posted

    As I've said in my previous post, there is no reliable way to gain direct access to the clipboard. I would recommend something like a button showing a popup with a copy/paste friendly textarea.

    Wednesday, June 22, 2011 4:29 AM
  • User-668204308 posted

    I couldn't agree more. Would be a lot easier to implement, too.

    Wednesday, June 22, 2011 4:42 AM