Clipboard Question

N

Newbie

Hi Group!

I am using asp.net 1.1 with vb.net 2003

In an asp.net page I click a button to return a result

I would like to add a button or link that selects the entire result of the
lblResult control text & copies it to the clipboard

How do I do this

TIA

ASP.NET Newbie
 
N

Newbie

Thanks for your reply but its not what I want at all

If you have a asp label with some text in it

I want to be able to click a link or a button to send that label's text to
the clipboard, that's all

MVP's should't reply with useless links, as I am looking for 1) VB.NET
server side code or 2) javascript that runs off a server control
 
M

Michael Schwarz

Hi "Newbie",


Newbie said:
Thanks for your reply but its not what I want at all

If you have a asp label with some text in it

I want to be able to click a link or a button to send that label's text to
the clipboard, that's all


MVP's should't reply with useless links, as I am looking for 1) VB.NET
server side code or 2) javascript that runs off a server control

You don't need VB.NET server-side code for this because server-side cannot
copy text to the clipboard, that is the reason for the link where you will
find the JavaScript source code you need for this action. But here is the
VB.NET code if you have a label called Label1 and a button called Button1:


Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Button1.OnClientClick =
"window.clipboardData.setData('Text',document.getElementById('" + _
Label1.ID + "').innerHTML);"
End Sub

--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.ajaxpro.info/
 
N

Newbie

OnClientClick is not a member of web control buttons is the error I get when
adding your code to the vb code behind the asp.net page
 
M

Michael Schwarz

This is .NET 2.0 sourc code, if you use it in .NET 1.1 you will use this
code:

Button1.Attributes.Add("onclick",
"window.clipboardData.setData('Text',document.getElementById('" + _
Label1.ID + "').innerHTML);"


Note, that you should use the HtmlButton instead of the
System.Web.UI.WebControls.Button.


--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.ajaxpro.info/
 

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

Similar Threads

Clipboard 2
clipboard / ajax 2
Add to clipboard 2
Use clipboard in web app 2
Writing to the clipboard 1
clipboard 7
Paste from clipboard in asp.net 1
Getting text to the Clipboard directly 0

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top