473,587 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copying to the clipboard


....working with visualweb.net 2005 and vb.

....trying to simply copy the contents from a textbox to the clipboard.

I've looked at a large number of places on line and they give me various
code, but it doesn't work. I'm apparently missing some type of declaration,
and the code is diffent in visualweb.net than elsewhere.
When I try the code below, it tells me that the "name clipboard is not
declared"

What am I missing?

Thanks

Jeff
Protected Sub BtnCopy_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles BtnCopy.Click
Clipboard.SetDa taObject(TextBo x1.Text)
End Sub

--
Posted via a free Usenet account from http://www.teranews.com

Jan 14 '07 #1
19 8716
If it isn't recognizing the name Clipboard, then you haven't got the
namespace that contains the Clipboard class imported.
"Jeff" <no**@none.comw rote in message
news:45******** **************@ free.teranews.c om...
>
...working with visualweb.net 2005 and vb.

...trying to simply copy the contents from a textbox to the clipboard.

I've looked at a large number of places on line and they give me various
code, but it doesn't work. I'm apparently missing some type of
declaration, and the code is diffent in visualweb.net than elsewhere.
When I try the code below, it tells me that the "name clipboard is not
declared"

What am I missing?

Thanks

Jeff
Protected Sub BtnCopy_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles BtnCopy.Click
Clipboard.SetDa taObject(TextBo x1.Text)
End Sub

--
Posted via a free Usenet account from http://www.teranews.com

Jan 14 '07 #2

"Scott M." <s-***@nospam.nosp amwrote in message
news:eU******** ******@TK2MSFTN GP04.phx.gbl...
If it isn't recognizing the name Clipboard, then you haven't got the
namespace that contains the Clipboard class imported.
Thanks, but I'm still new at this. Could you please explain how to do that?

Jeff
--
Posted via a free Usenet account from http://www.teranews.com

Jan 14 '07 #3
Jeff,

See if you have a reference to the 'System.Windows .Forms' class for a start

Then you can use your code as normal to copy to the clipboard

If you then want to paste the clipboard data then use this code:

Dim iData As IDataObject = Clipboard.GetDa taObject()
TextBox1.Text = CType(iData.Get Data(DataFormat s.Text), String)

I used TextBox1 to hold the pasted text

I hope this helps,

Newbie Coder
Jan 15 '07 #4
Hi Jeff,

To use the clipboard in a windows form app, you have to reference to the
System.Windows. Forms assembly. By default, when you create the project, it
was automatically added. If it isn't there, you can add it using Add
Referece.

Then all you need to do is to use SetDataObject method. If you didn't
import the namespace, you just need to add namespace before the class name,
like the following.

Protected Sub BtnCopy_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles BtnCopy.Click
System.Windows. Forms.Clipboard .SetDataObject( TextBox1.Text)
End Sub

By the way, this can only be used in a windows form app. For web app, doing
clipboard operations at client side involves scripting.

Kevin Yu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jan 15 '07 #5

"Kevin Yu [MSFT]" <v-****@online.mic rosoft.comwrote in message
news:W5******** ******@TK2MSFTN GHUB02.phx.gbl. ..
By the way, this can only be used in a windows form app. For web app,
doing
clipboard operations at client side involves scripting.

Kevin Yu
Microsoft Online Community Support

Okay, this must be the problem. I found similar instructions to what you and
the other poster provided, but I am attempting this on a web app.

Is there an easy way get the text from a dot.net text box in a web app into
the clipboard using javascript or similar script after clicking a dot.net or
html button?

Jeff

--
Posted via a free Usenet account from http://www.teranews.com

Jan 15 '07 #6
Hi Jeff,

On the webpage, you have to achieve this with client side scripts. Here are
many examples for your refrence. If anything is unclear, please feel free
to let me know.

http://www.microsoft.com/technet/scr.../aug04/hey0813.
mspx

http://www.htmlgoodies.com/beyond/ja...le.php/3458851

Kevin Yu
Microsoft Online Community Support
=============== =============== =============== =====

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jan 15 '07 #7
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaS cript">

function ClipboardSend()
{
clipboardData.s etData("text",t xtTest.value)
}

</SCRIPT>
</HEAD>
<BODY>

<Input type="text" ID="txtTest">
<Input type="button" onClick="Clipbo ardSend()" Value="Copy To Clipboard">

</BODY>
<HTML>
"Jeff" <no**@none.comw rote in message
news:45******** **************@ free.teranews.c om...
>
"Kevin Yu [MSFT]" <v-****@online.mic rosoft.comwrote in message
news:W5******** ******@TK2MSFTN GHUB02.phx.gbl. ..
>By the way, this can only be used in a windows form app. For web app,
doing
clipboard operations at client side involves scripting.

Kevin Yu
Microsoft Online Community Support


Okay, this must be the problem. I found similar instructions to what you
and the other poster provided, but I am attempting this on a web app.

Is there an easy way get the text from a dot.net text box in a web app
into the clipboard using javascript or similar script after clicking a
dot.net or html button?

Jeff

--
Posted via a free Usenet account from http://www.teranews.com

Jan 15 '07 #8

"Kevin Yu [MSFT]" <v-****@online.mic rosoft.comwrote in message
news:oM******** ********@TK2MSF TNGHUB02.phx.gb l...
On the webpage, you have to achieve this with client side scripts. Here
are
many examples for your refrence. If anything is unclear, please feel free
to let me know.

http://www.microsoft.com/technet/scr.../aug04/hey0813.
mspx

http://www.htmlgoodies.com/beyond/ja...le.php/3458851

Kevin Yu
I get the general idea, but I'm new to VB and even newer to scripting so I'm
missing one or two details.
The first page you pointed to above looks promising for my application. What
I'm doing is having the application produce text that is visible in a
textbox - that part's okay. I would then like the user to be able to click a
button and have that text copied to the clipboard. I tried the code below
that is similar to what was suggested on the first page. I get no warnings
during development, but when I attempt to run it, the client side browser
produces an error that the active-X component could not be created (IE7 on
vista rc1 - I haven't tested elsewhere).

What might I be still missing?
Jeff

Protected Sub BtnCopy_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles BtnCopy.Click
Dim objIE
Dim strCopy As String

strCopy = "This text has been copied to the clipboard."

objIE = CreateObject("I nternetExplorer .Application")
objIE.Navigate( "about:blan k")
objIE.document. parentwindow.cl ipboardData.Set Data("text", strCopy)
objIE.Quit()

End Sub

--
Posted via a free Usenet account from http://www.teranews.com

Jan 15 '07 #9
I wouldn't try to solve this with server-side VB.NET code. As pointed out,
the clipboard is a client-side object and so the best place to put your code
is on the client (JavaScript).

Simply add the following JavaScript function to your HTML (in the <HEAD>
section):

<SCRIPT LANGUAGE="JavaS cript">

function ClipboardSend()
{
clipboardData.s etData("text",t xtTest.value)
}

</SCRIPT>
Then, further down in your HTML (probably right after the code for your
textbox), add the following code to create the client-side button that takes
the text from your textbox and puts it on the clipboard:

<Input type="button" onClick="Clipbo ardSend()" Value="Copy To Clipboard">

That should do it.

Good luck,

-Scott
"Jeff" <no**@none.comw rote in message
news:45******** **************@ free.teranews.c om...
>
"Kevin Yu [MSFT]" <v-****@online.mic rosoft.comwrote in message
news:oM******** ********@TK2MSF TNGHUB02.phx.gb l...
>On the webpage, you have to achieve this with client side scripts. Here
are
many examples for your refrence. If anything is unclear, please feel free
to let me know.

http://www.microsoft.com/technet/scr.../aug04/hey0813.
mspx

http://www.htmlgoodies.com/beyond/ja...le.php/3458851

Kevin Yu

I get the general idea, but I'm new to VB and even newer to scripting so
I'm missing one or two details.
The first page you pointed to above looks promising for my application.
What I'm doing is having the application produce text that is visible in a
textbox - that part's okay. I would then like the user to be able to click
a button and have that text copied to the clipboard. I tried the code
below that is similar to what was suggested on the first page. I get no
warnings during development, but when I attempt to run it, the client side
browser produces an error that the active-X component could not be created
(IE7 on vista rc1 - I haven't tested elsewhere).

What might I be still missing?
Jeff

Protected Sub BtnCopy_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles BtnCopy.Click
Dim objIE
Dim strCopy As String

strCopy = "This text has been copied to the clipboard."

objIE = CreateObject("I nternetExplorer .Application")
objIE.Navigate( "about:blan k")
objIE.document. parentwindow.cl ipboardData.Set Data("text", strCopy)
objIE.Quit()

End Sub

--
Posted via a free Usenet account from http://www.teranews.com

Jan 15 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6899
by: Gey-Hong Gweon | last post by:
Is there a way to copy a PIL image to windows clipboard (as a dib image or a bitmap, I suppose)? What I would like to accomplish is to do a fast copy and paste of images from my python application to a windows application such as powerpoint. A slower way is to use files, which is what I am doing at the moment. Thanks in advance.
0
568
by: Ata | last post by:
Hello, I am trying to copy the contents of the output of SQL Reporting Services to a PowerPoint slide. For this, I am using SQL Reporting Services to obtain an IMAGE stream, which I paste to the Windows clipboard. Then, using automation, I am trying to copy this information from the clipboard to a PowerPoint slide. However, I get an error...
4
1551
by: buildmorelines | last post by:
I need a utility that will basically add a "Copy OnClick Event" to my right click context menu in Internet Explorer IE. I am a super newbie in javascript. The following code works for IE5, but not for IE4, which doesnt have setdata, getdata, etc. methods for dealing with the clipboard. The folowing code is invoked by a registry context menu...
16
12445
by: DataBard007 | last post by:
I have an Access97 application whose form contains many text boxes. What do I have to do in order to copy the contents of one of these text boxes to the clipboard? I want to do this so I can then paste from the clipboard to Word, Notepad, etc. I know about the SetClipboardData function, but I really can't figure out how it works. It's...
8
16193
by: John Smith | last post by:
Hi folks, I know how to place text into the user's clipboard: Clipboard.SetDataObject("My Copied Text"); but how do I place a file in there? So, if I have a file C:\test.txt, how can I place that file into the user's clipboard so that they can later paste it into explorer? Thanks!!!
9
2116
by: Christian Blackburn | last post by:
Hi Gang, I don't know what to make of all of this, but I'm having nothing, but trouble copying data to the clipboard which should be the easiest thing in the world. The only systems I can get this to not crash on is my development system w/ VB 2003 installed and Windows NT 4. My development system is Windows 2000 Pro, but if I try using the...
4
4523
by: fred | last post by:
I am trying to copy a file onto the clipboard but I am not having any success. Perhaps someone can help me out. I have the full file name from my application and to put it onto the clipboard I have tried: Clipboard.SetDataObject(New DataObject(DataFormats.FileDrop, myFileName), True) where myFileName is a string and contains the full...
4
5844
by: gordon | last post by:
Hi I hav e a smallish app that has a datagridview. A user can select some columns in the datagrid, and i have a button that i would like to use to copy the rows that are selected to the clipboard or to a text file. Any ideas how to accomplish this? I have all the controls working in this form apart from this feature.
0
1992
by: MathewJose | last post by:
Hi, I have a DatagridView in windows form.It has got a column which has some names that are populated from master table in database.Now i need to copy a set of data against these names. I tried to populate data to the first column from database and then tried to copy excel sheet data against each name but some exceptions are coming.It...
0
7915
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
8205
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
7967
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
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6619
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...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3840
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...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1185
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.