Connecting Tech Pros Worldwide Help | Site Map

reading clipboard

Jaez
Guest
 
Posts: n/a
#1: May 10 '07
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


Randy Webb
Guest
 
Posts: n/a
#2: May 10 '07

re: reading clipboard


Jaez said the following on 5/10/2007 9:11 AM:
Quote:
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/
Jaez
Guest
 
Posts: n/a
#3: May 10 '07

re: reading clipboard



"Randy Webb" <HikksNotAtHome@aol.comwrote in message
news:uqOdnYGYeuOv097b4p2dnA@giganews.com...
Quote:
Jaez said the following on 5/10/2007 9:11 AM:
Quote:
>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


Randy Webb
Guest
 
Posts: n/a
#4: May 10 '07

re: reading clipboard


Jaez said the following on 5/10/2007 2:41 PM:
Quote:
"Randy Webb" <HikksNotAtHome@aol.comwrote in message
news:uqOdnYGYeuOv097b4p2dnA@giganews.com...
Quote:
>Jaez said the following on 5/10/2007 9:11 AM:
Quote:
>>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>
Quote:
<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/
Closed Thread


Similar JavaScript / Ajax / DHTML bytes