By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,869 Members | 1,742 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,869 IT Pros & Developers. It's quick & easy.

Copy To Clipboard Not Working

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.