ASP Copy from Textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been looking in the newsgroup but cannot find what I need. I am using Visual Studio to to build a VB.Net application using System.Web.UI.Page NOT windows.forms. The server fills a textbox and sends it to the client. Initially I wanted to print the textbox but after viewing the complexity it was decided we did not want to spend that amount of time on this. Now the desire is for the client clicking a "button" to have the contents of the textbox copied to the windows clipboard so they can paste the textbox contents into Word or Notepad. Please help - Thanks.
 
You are trying to have the web server copy information to the client
clipboard? You can't do this. The nature of ASP.NET is that when the code
executes, it is executing on a web server somewhere. When that code is done
executing (emphasis on "done"), it returns the results of the code (emphasis
on results) to the calling client.

You never have a dedicated real-time connection between the client and
server for the purposes of code processing. It pretty much boils down to
your ASP.NET code can control and "talk" to elements accessible to the
server and your resulting HTML can control and "talk" to elements accessible
to the client.

But because neither HTML or JavaScript give you an API to the client Windows
clipboard, you are out of luck.

However, users can still use the traditional ways to cut, copy and paste
(keyboard shortcuts, right clicking).


Michael SL said:
I have been looking in the newsgroup but cannot find what I need. I am
using Visual Studio to to build a VB.Net application using
System.Web.UI.Page NOT windows.forms. The server fills a textbox and sends
it to the client. Initially I wanted to print the textbox but after viewing
the complexity it was decided we did not want to spend that amount of time
on this. Now the desire is for the client clicking a "button" to have the
contents of the textbox copied to the windows clipboard so they can paste
the textbox contents into Word or Notepad. Please help - Thanks.
 
Scot

I guess I was not clear. I want the client to have a button available which when clicked copies the contents of a textbox without the server ever knowing it occurred. I figure this has to be done through a script which is part of the HTML but I have not been able to figure out how to make this happen. Thanks - Michael
 
IE supports the clipboardData object in its Browser Object Model. To use
it, do something similiar to this:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">

function ClipboardSend()
{
clipboardData.setData("text",txtTest.value)
}

</SCRIPT>
</HEAD>
<BODY>

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

</BODY>
<HTML>

I can't say if this will work in other non IE browsers.

Good luck.


Michael SL said:
Scott

I guess I was not clear. I want the client to have a button available
which when clicked copies the contents of a textbox without the server ever
knowing it occurred. I figure this has to be done through a script which is
part of the HTML but I have not been able to figure out how to make this
happen. Thanks - Michael
 
That works! Thanks a lot. -- Michae

----- Scott M. wrote: ----

IE supports the clipboardData object in its Browser Object Model. To us
it, do something similiar to this

<HTML><HEAD><SCRIPT LANGUAGE="JavaScript"

function ClipboardSend(

clipboardData.setData("text",txtTest.value


</SCRIPT></HEAD><BODY><Input type="text" ID="txtTest"><Input type="button" onClick="ClipboardSend()" Value="Copy To Clipboard"></BODY><HTML

I can't say if this will work in other non IE browsers

Good luck


Michael SL said:
which when clicked copies the contents of a textbox without the server eve
knowing it occurred. I figure this has to be done through a script which i
part of the HTML but I have not been able to figure out how to make thi
happen. Thanks - Michae
 
Hi

I was currious about this, and searched for it on Google,

See this link, it gives also a more complete answer on the question.
It is half Dutch and half English, but the main things are English I saw.

Cor
 
Back
Top