Clipboard Question

  • Thread starter Thread starter Newbie
  • Start date Start date
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
 
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
 
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/
 
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
 
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/
 
Back
Top