473,320 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Copy To Clipboard Not Working

I am trying to copy the text from a textbox to the clipboard. I saw some
code posted earlier for Pasting from the clipboard so I modified it for copy
but it is not working (see code below). When I click on the
btnCopyToClipboard I can see some processing going on but the text from the
textbox is not being put on the clipboard?

Thoughts or suggestions?

Wayne
====================================
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then

btnCopyToClipboard.Attributes.Add("onclick", "CopyIt();return false;")

Page.RegisterClientScriptBlock("copyroutine", _

"<script>function CopyIt()" & _

"{document.all.txtHidden.focus();" & _

"document.execCommand('copy');}</script>")

End If

End Sub
Nov 19 '05 #1
2 2281
After thinking about this code (I know very little javascript) and googling
for ideas I am pretty sure the problem is with the

"{document.all.txtHidden.focus();"

phrase. I suspect that the code needs to be changed to something that
actually selects the text in that text box instead of just giving it focus.
I am going to experiment with "InnerHTML" to see what happens.

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:ut*************@TK2MSFTNGP14.phx.gbl...
I am trying to copy the text from a textbox to the clipboard. I saw some
code posted earlier for Pasting from the clipboard so I modified it for copy but it is not working (see code below). When I click on the
btnCopyToClipboard I can see some processing going on but the text from the textbox is not being put on the clipboard?

Thoughts or suggestions?

Wayne
====================================
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then

btnCopyToClipboard.Attributes.Add("onclick", "CopyIt();return false;")

Page.RegisterClientScriptBlock("copyroutine", _

"<script>function CopyIt()" & _

"{document.all.txtHidden.focus();" & _

"document.execCommand('copy');}</script>")

End If

End Sub

Nov 19 '05 #2
I just re-posted this over in the dotnet.languages.jscript forum - I didn't
have that on my list before.

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:ut*************@TK2MSFTNGP14.phx.gbl...
I am trying to copy the text from a textbox to the clipboard. I saw some
code posted earlier for Pasting from the clipboard so I modified it for copy but it is not working (see code below). When I click on the
btnCopyToClipboard I can see some processing going on but the text from the textbox is not being put on the clipboard?

Thoughts or suggestions?

Wayne
====================================
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then

btnCopyToClipboard.Attributes.Add("onclick", "CopyIt();return false;")

Page.RegisterClientScriptBlock("copyroutine", _

"<script>function CopyIt()" & _

"{document.all.txtHidden.focus();" & _

"document.execCommand('copy');}</script>")

End If

End Sub

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: XmlAdoNewbie | last post by:
Hi All, I would like to put a method for copy, cut and paste into my application and this seems to be easy enough except that it's not working the way i would like it to, I thought someone might...
4
by: Wayne Wengert | last post by:
I have an aspx page on which I am trying to copy the contents of a textbox to the client clipboard when the users clicks a button. The button code is as follows:...
5
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in...
2
by: Keith | last post by:
I'm trying to come up with a way to create a contextmenu that will do all the "standard" functions (cut, copy, paste, undo, etc). There seems to be a lot of information out there - but nothing...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
0
by: mhospodarsky | last post by:
Hi-- I am using VB.Net 2002 for this app. I am working with Tiff and jpeg images. I have a picturebox set up that I use to view the images. I have the picture box inside of a scrollable...
6
by: Ben R. | last post by:
Hi, I've got a vb.net winforms app. Out of the box, I can use Ctrl X, C and V as expected in controls like textboxes. I've got a menustrip, and if I click the link "Add standard items" which...
17
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have...
0
by: Curious | last post by:
I'm working on fixing the command of "Copy to Clipboard" from a data grid. The current implementation has two problems: 1) There are two extra columns copied to clipboard that are invisible...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.