Getting text to the Clipboard directly

T

tshad

I am creating a string with data from my GridView in a CSV format that I
want to write to a file. I am trying to write the data into the Clipboard
and allowing the user to paste the data into the notepad and then saving the
file, since there doesn't seem to be a way to do that directly from the web
page.

I finally figure out how to do it by putting the data into a string, moving
the string to a textbox and then executing a javascript function to read the
data from the textbox and copy the data to the clipboard:
function ClipBoardTest()
{
var txt = document.getElementById("<%= MyText.ClientID %>");
window.clipboardData.setData("Text", txt.value);
}

But this means I have to put the data into a string (stringbuilder) and then
copy that to the textbox.

Is there a way to call the javescript directly and pass the string to it and
have it do the clipboard function on the string?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top