473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

reading clipboard

As a newbie to javascript and asp.net 2 I have come across a problem related
to the windows clipboard.

I have written an application in vb6 which collects data and puts it on the
user's clipboard in windows. On leaving that application it opens my webpage
in IE6 or 7. The page displays a text box and the user is required to paste
the clipboard into the text box.

I read about window.clipboardData.getData('Text') and it seems an idea way
of pasting the contents of the clipboard straight into the text box during
webpage load.

My problem is that my pages are written in asp.net 2 (VB style) and I have
failed in all attempts to get the clipboard to paste to an asp.net textbox.
I realise that its a job for javascript on the client side.

What i need is something like

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
textbox2.text=window.clipboardData.getData("Text") ;
End Sub

I have also tried

response.write("<script
type='text/javascript'>textbox2.text=window.clipboardData.get Data('Text')</script>");

I rather suspect that I need to make a jasvascript function but have no idea
how to make a function that returns a variable that can be picked up in
asp.net during form load

All help appreciated

Jaez
May 10 '07 #1
3 7238
Jaez said the following on 5/10/2007 9:11 AM:
As a newbie to javascript and asp.net 2 I have come across a problem related
to the windows clipboard.

I have written an application in vb6 which collects data and puts it on the
user's clipboard in windows. On leaving that application it opens my webpage
in IE6 or 7. The page displays a text box and the user is required to paste
the clipboard into the text box.

I read about window.clipboardData.getData('Text') and it seems an idea way
of pasting the contents of the clipboard straight into the text box during
webpage load.

My problem is that my pages are written in asp.net 2 (VB style) and I have
failed in all attempts to get the clipboard to paste to an asp.net textbox.
I realise that its a job for javascript on the client side.

What i need is something like

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
textbox2.text=window.clipboardData.getData("Text") ;
End Sub

I have also tried

response.write("<script
type='text/javascript'>textbox2.text=window.clipboardData.get Data('Text')</script>");

I rather suspect that I need to make a jasvascript function but have no idea
how to make a function that returns a variable that can be picked up in
asp.net during form load
Pure clientside JS (there are probably other ways):

window.onload = setValue;

function setValue(){
textbox2.value=window.clipboardData.getData('Text' )
}

You set a value, not the .text. Also, you may want to break the habit of
using the IE shortcut of textbox2 referring to an element with ID/NAME
of textbox2 as it will break any browser other than IE.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 10 '07 #2

"Randy Webb" <Hi************@aol.comwrote in message
news:uq********************@giganews.com...
Jaez said the following on 5/10/2007 9:11 AM:
>As a newbie to javascript and asp.net 2 I have come across a problem
related to the windows clipboard.

I have written an application in vb6 which collects data and puts it on
the user's clipboard in windows. On leaving that application it opens my
webpage in IE6 or 7. The page displays a text box and the user is
required to paste the clipboard into the text box.

I read about window.clipboardData.getData('Text') and it seems an idea
way of pasting the contents of the clipboard straight into the text box
during webpage load.

My problem is that my pages are written in asp.net 2 (VB style) and I
have failed in all attempts to get the clipboard to paste to an asp.net
textbox. I realise that its a job for javascript on the client side.

What i need is something like

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
textbox2.text=window.clipboardData.getData("Text") ;
End Sub

I have also tried

response.write("<script
type='text/javascript'>textbox2.text=window.clipboardData.get Data('Text')</script>");

I rather suspect that I need to make a jasvascript function but have no
idea how to make a function that returns a variable that can be picked up
in asp.net during form load

Pure clientside JS (there are probably other ways):

window.onload = setValue;

function setValue(){
textbox2.value=window.clipboardData.getData('Text' )
}

You set a value, not the .text. Also, you may want to break the habit of
using the IE shortcut of textbox2 referring to an element with ID/NAME of
textbox2 as it will break any browser other than IE.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/

Thanks Randy

I have tried adding the code in a number of ways and am still stuck
I get TexBox1 undefined

Here is my test page

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

Response.Write("<script type='text/javascript'window.onload = setValue;
function
setValue(){TextBox1.value=window.clipboardData.get Data('Text')}</scr" &
"ipt>")

End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)

Response.Write("<script type='text/javascript'window.onload = setValue;
function
setValue(){TextBox1.value=window.clipboardData.get Data('Text')}</scr" &
"ipt>")

End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

&nbsp;<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />

<asp:TextBox ID="TextBox1" runat="server" Height="70px"
Width="531px"></asp:TextBox>

<script type='text/javascript'window.onload = setValue; function
setValue(){TextBox1.value=window.clipboardData.get Data('Text')}</script>

</form>

</body>

</html>

Jaez
May 10 '07 #3
Jaez said the following on 5/10/2007 2:41 PM:
"Randy Webb" <Hi************@aol.comwrote in message
news:uq********************@giganews.com...
>Jaez said the following on 5/10/2007 9:11 AM:
>>As a newbie to javascript and asp.net 2 I have come across a problem
related to the windows clipboard.

I have written an application in vb6 which collects data and puts it on
the user's clipboard in windows. On leaving that application it opens my
webpage in IE6 or 7. The page displays a text box and the user is
required to paste the clipboard into the text box.

I read about window.clipboardData.getData('Text') and it seems an idea
way of pasting the contents of the clipboard straight into the text box
during webpage load.

My problem is that my pages are written in asp.net 2 (VB style) and I
have failed in all attempts to get the clipboard to paste to an asp.net
textbox. I realise that its a job for javascript on the client side.

What i need is something like

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
textbox2.text=window.clipboardData.getData("Text") ;
End Sub

I have also tried

response.write("<script
type='text/javascript'>textbox2.text=window.clipboardData.get Data('Text')</script>");

I rather suspect that I need to make a jasvascript function but have no
idea how to make a function that returns a variable that can be picked up
in asp.net during form load
Pure clientside JS (there are probably other ways):

window.onload = setValue;

function setValue(){
textbox2.value=window.clipboardData.getData('Text ')
}

You set a value, not the .text. Also, you may want to break the habit of
using the IE shortcut of textbox2 referring to an element with ID/NAME of
textbox2 as it will break any browser other than IE.

Thanks Randy

I have tried adding the code in a number of ways and am still stuck
I get TexBox1 undefined
<snip>
<form id="form1" runat="server">

&nbsp;<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />

<asp:TextBox ID="TextBox1" runat="server" Height="70px"
Width="531px"></asp:TextBox>

<script type='text/javascript'window.onload = setValue; function
setValue(){TextBox1.value=window.clipboardData.get Data('Text')}</script>
document.forms['form1'].elements['TextBox1'].value

It is, partially, the IE shortcut problem. Also, don't post the server
side code, post the code the client gets.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 10 '07 #4

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

Similar topics

8
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a...
1
by: B. Cline | last post by:
Hi, I need to write a conversion routine to split pictures out of about 10000 word documents. (Actually the text is converted to RTF, the pictures should be converted to jpg). I thought I...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
3
by: Phil Endecott | last post by:
Dear All, I'm trying to read the content of the clipboard in a cross-browser way. Google will find various scripts such as this one: ...
0
by: Tony Johansson | last post by:
Hello!! I'm reading a book and there is something that I have found that may me unnessessary. It's a method called ReadClipboard listed below. It read an object from the Clipboard and return...
0
by: jen | last post by:
this works fine it i operate on one .doc file; however, if i process multiple files, i get the following error: Requested Clipboard operation did not succeed. i suspect i need to clear my...
15
by: Peter Duniho | last post by:
I'm trying to use .NET and C# to draw a metafile copied to the clipboard by another application (Word 2003 in this case, but it shouldn't matter). I naively thought that I'd be able to use the...
1
by: Figmo | last post by:
Wow.....this is darned odd.... I have an app that integrates with other applications. It registers a global hotkey with Windows. When the hotkey executes it sends a CTRL-C to the active...
20
by: Joe Duchtel | last post by:
Hello - I have the following code to get a bitmap from the clipboard and to save it to a *.png file ... Dim lData As IDataObject = Clipboard.GetDataObject() If...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.