How to get the contnet of clipboard

E

Edwin Knoppert

MSIE supports obtaining the user's clipboard.
Once obtained it is easy to transmit to the server.
 
C

Craig Deelsnyder

Edwin said:
MSIE supports obtaining the user's clipboard.
Once obtained it is easy to transmit to the server.


Craig Deelsnyder said:
client-side (on the user's PC): you can't. you don't have access to it...

server-side:
http://msdn.microsoft.com/library/d...rlrfsystemwindowsformsclipboardclasstopic.asp

Yikes, you're right! Tells you how often I build IE-specific
applications, not to say other browsers might not have given this
capability. Me as a user? I don't like it....do you know if you get
cross-domain access (read stuff I copied while browsing a different domain)?

Anyway, I dug this up after Edwin's reply...

http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/clipboardData.asp

looks like it only works for text that is copy/paste using the menus in
IE (not using shortcut keys)? Just figuring this out for myself as well...
 
J

Juan T. Llibre

re:
MSIE supports obtaining the user's clipboard.
Once obtained it is easy to transmit to the server.

Please post sample code.




Edwin Knoppert said:
MSIE supports obtaining the user's clipboard.
Once obtained it is easy to transmit to the server.
 
E

Edwin Knoppert

I did see this work on a live website, not mine.
It did work.
It was there to proof that the CB could be read.

Juan T. Llibre said:
re:
MSIE supports obtaining the user's clipboard.
Once obtained it is easy to transmit to the server.

Please post sample code.
 
J

Juan T. Llibre

I would have liked to see sample code for doing that,
in ASP.NET, if it's that easy.

Maybe you didn't take into account that the clipboard class
is in the System.Windows.Forms namespace ( which, as
Craig told you, cannot be accessed by ASP.NET server-side ) ?

Even if it were to be accessed, it would be the *server's* clipboard
that's accessed, if this thing is running server-side, wouldn't it ?

So, that leaves, as the only alternative, to write a client-side program
which captures client data, in sync with the current ASP.NET context,
have the user install it and run it so that the correct data is captured client-side,
and figure out a way to insert the clipboard's contents to the server, in context
with the current request.

That last part doesn't seem too complicated, although it's certainly not "easy".

The first part certainly is complicated, and that's why I wondered why you
described the procedure as "once obtained it is easy to transmit to the server".

That "once obtained" is what you overlooked.
 
E

Edwin Knoppert

I don't think you listen well, i said client side.
Has nothing to do with ASP.NET etc..
 
E

Edwin Knoppert

Hmm, maybe i was to harsh.
But you get the idea.
It must be seen as local stuff.
 
J

Juan T. Llibre

re:
Hmm, maybe i was to harsh.

Nah, you weren't "harsh". You were mistaken.
I know it's hard to accept that sometimes.

re:
It must be seen as local stuff.

That task is not simply "local stuff". There's a server involved.

Passing the contents of a client's clipboard to an IIS server
running ASP.NET is not a trivial undertaking. Not in the least.




Edwin Knoppert said:
Hmm, maybe i was to harsh.
But you get the idea.
It must be seen as local stuff.
 
E

Edwin Knoppert

We must see it differently then.
A js function can be called to obtain the CB, this could be onload.
If you have the CB text you can invoke a post to the server.

What 's not trivial?
Unless you expect to read other CB formats like EMF or so?
 
J

Juan T. Llibre

And if I have an image in the clipboard ?

Anyway, having your clipboard read by a web page is a security risk.

To make sure your clipboard is not exposed :

1. In Internet Explorer, go to Tools -> Internet Options -> Security
2. Click on Custom Level
3. In the security settings, click to Disable the “Allow Paste Operations via Script.”

That will keep your clipboard text contents private,
and will prevent you from doing what you are proposing to do.

Simply turning off Javascript
( which more and more people are doing these days )
will prevent the reading of text from a client's clipboard, too.

IOW, client behavior is easily derailed, so it's not a general solution.
That lands us right back into the server scenario again, where it simply can't be done.

The idea is not only whether a programming sequence is feasible,
but also whether it's practical, reliable and secure.
 
E

Edwin Knoppert

Simply turning off Javascript
Eeek!
I wonder how ASP.NET reacts :)
+ a lot of my code is in javascript
I consider that a minimal requirement.
 
J

Juan T. Llibre

re:

heh, heh...

Good reaction ... ;-)

re:
I wonder how ASP.NET reacts :)
+ a lot of my code is in javascript
I consider that a minimal requirement.

No web server, no matter the technology used,
can function as efficiently without client-side Javascript as with it.

Some things work fine without JS, like server-side form validation.
Other fail miserably.

Worse, not even detecting browsers can tell you if JS has been disabled,
or even if paste operations via script have been disabled, which many
companies do disable as part of their security policy.

The only way is to test for JS involves using JS. What a catch-22!

If you pass a variable and the variable is there, JS is running.
If it's not there, it's not.
 
C

Craig Deelsnyder

Juan said:
re:

Please post sample code.

Juan, see my reply (sibling post of yours) for a quick example, or one
way of doing it. It does work, but this example is somewhat limited in
its effectiveness.

Which going back to the conversation you and Edwin had (further below in
this thread) there's a lot of reasons to not do this unless you're in a
very controlled environment where you know it's even possible to work
all the time.
 
J

Juan T. Llibre

re;
there's a lot of reasons to not do this unless you're in a very controlled environment
where you know it's even possible to work all the time.

Yeah, that's what I've been trying to explain to Edwin in the thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,614
Members
45,287
Latest member
Helenfem

Latest Threads

Top