Q
Problem solve Get help with specific problems with your technologies, process and projects.

How can I copy text from a textbox to a clipboard through a Web Form?

How can I copy text from a textbox to a clipboard through a Web Form? I am developing in C#.
The clipboard is a typical UI feature, used by end users. In ASP.NET, the target UI is the browser, obviously, and there's no way to code anything in the browser (client-side) with C#, which runs on the server when the page is processed. Thus, there's no purpose in copying things to the clipboard on the server. There's no user to pick it later! And it would be dangerous to rely on such a mechanism to pass data around, as it's shared by the whole operating system, thus multiple Web application may overwrite each other's data, etc.

On the other hand, if you're looking at copying to the clipboard on the client-side (the browser), you need to do so with JavaScript. However, there's no homogenous, cross-browser, cross-platform, standard way of doing that. In Windows AND IE you can use the window.clipboardData object, as explained at http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/clipboarddata.asp. In Mozilla, it requires a "little" more work, as explained at http://www.krikkit.net/howto_javascript_copy_clipboard.html.

This was last published in September 2003

Dig Deeper on C# programming language

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

SearchCloudApplications

Close