469,625 Members | 1,708 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

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

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-he...t-and-copy-to-
clipboard.htm

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

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2"
Runat="Server">
<script language="javascript" type="text/javascript">
<!--

// -->
</script>

<br />
Click the radio button of the list you want to create and then click the
"Create
List" button.<br />
<br />
You can select all the itmes in the list and copy/paste it to wherever
you need
it.
</asp:Content>
The ID of my literal control is: "ltrlStudentList"
Thanks,

Keith

Jun 27 '08 #1
0 1076

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Wayne Wengert | last post: by
4 posts views Thread by Wayne Wengert | last post: by
8 posts views Thread by Michael SL | last post: by
7 posts views Thread by lgbjr | last post: by
17 posts views Thread by Steve | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.