Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting & Copying Text from a Textbox to Clipboard 1

Status
Not open for further replies.

mark929

Programmer
Nov 30, 2001
67
0
0
US
I am creating a form that collects text from various inputs; checkboxes, Dropdown Lists, etc, and puts it all in one Textbox.

I would like to put a "Select All" button and a "Copy" button on the same form to allow users to select and copy all the text in the Textbox1 to the clipboard. Even better, would be one button to do both. The copied text would then be "Pasted" into a separate application. This is a convenience thing, and would eliminate the user having to RightClick/SelectAll and RightClick/Copy.

Can anyone get me started on the code behind the button, or point me to somewhere I could research it. I'm new to ASP/VB.Net and nothing I have tried so far has worked.

Thanks

Mark Roberts

 
This will do it for one field I know, Maybe you can go with it from there...

javascript:
function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&&copytoclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
}
}
code behind:
Me.cmdCopy.Attributes.Add("OnClick", "javascript:HighlightAll('Timer.txtTotalTime')")
 
Thanks Checkai, I'll give this a try.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top