473,566 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
btnCopyToClipbo ard 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.EventArg s) Handles MyBase.Load

If Not IsPostBack Then

btnCopyToClipbo ard.Attributes. Add("onclick", "CopyIt();retur n false;")

Page.RegisterCl ientScriptBlock ("copyroutin e", _

"<script>functi on CopyIt()" & _

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

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

End If

End Sub
Nov 19 '05 #1
2 2296
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******** *****@TK2MSFTNG P14.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
btnCopyToClipbo ard 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.EventArg s) Handles MyBase.Load

If Not IsPostBack Then

btnCopyToClipbo ard.Attributes. Add("onclick", "CopyIt();retur n false;")

Page.RegisterCl ientScriptBlock ("copyroutin e", _

"<script>functi on CopyIt()" & _

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

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

End If

End Sub

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

Wayne

"Wayne Wengert" <wa************ ***@wengert.com > wrote in message
news:ut******** *****@TK2MSFTNG P14.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
btnCopyToClipbo ard 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.EventArg s) Handles MyBase.Load

If Not IsPostBack Then

btnCopyToClipbo ard.Attributes. Add("onclick", "CopyIt();retur n false;")

Page.RegisterCl ientScriptBlock ("copyroutin e", _

"<script>functi on CopyIt()" & _

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

"document.execC ommand('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
3063
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 be able to give me a bit of insight and for that I say Thank You in advance! this is what I have so far. private void CutText() {
4
9182
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: ===================================== Private Sub btnCopyToClipboard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopyToClipboard.Click ...
5
21007
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 windows explorer: when you do a right-click on a file and choose Copy, and than paste it somewhere in my application and vice versa.
2
2671
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 seems to work for me. A few people refer to txt.copy() txt.paste(), etc. I'm not sure if those are old functions, but they do not work for me. ...
7
11608
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 is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an...
0
2645
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 panel.There are two viewing preferences available: to view the image with scrollbars (the original image unsized), and to view the iamge without...
6
9631
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 adds Cut copy and paste commands, this functionality no longer works. It seems now I need to implement handlers for these functions. I tried to do so,...
17
5088
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 about 20 textboxes on the form). Also to ensure that the button can't get used if the cursor isn't in a textbox field. And to ensure the contents of...
0
1401
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 in the grid. I'll need to remove these two columns from clipboard. 2) The headings are not being copied to clipboard.
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.