how to copy contents of literal to clipboard via button on a page?

how to copy contents of literal to clipboard via button on a page?

am 13.04.2008 02:32:40 von Keith G Hicks

asp.net 2.0

Well until I started looking for how to do this I figured it would be very
easy and lots of information out there. Maybe I'm not looking in the right
places.

I have some code in VB that's creating a list of names and populating a
literal control on the page. I'd like to put a button on the page that let's
the user copy the contents of the literal to the clipboard. As I write this
I'm thinking this probably needs to be client side JS instead of serverside
VB. I'm not very familiar yet with JS so any help anyone can give me would
be greatly appreciated.

I found this but have no idea how to implement it into my page markup.
Please assume I'm in about 1st grade when it comes to JS.

window.fCopyToClipboard = function(rSource){ rSource.select()
if(window.clipboardData){ var r=clipboardData.setData('Text',rSource.value);
return 1; } else return 0 }

the above code is from this site:
http://www.esqsoft.com/javascript-help/how-to-select-html-in put-and-copy-to-
clipboard.htm

I assume it needs to fit into here somehow but I don't know the details:

Runat="Server">




Click the radio button of the list you want to create and then click the
"Create
List" button.



You can select all the itmes in the list and copy/paste it to wherever
you need
it.



The ID of my literal control is: "ltrlStudentList"


Thanks,

Keith