Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Paste from clipboard in asp.net

Reply
Thread Tools

Paste from clipboard in asp.net

 
 
=?Utf-8?B?ZnM=?=
Guest
Posts: n/a
 
      02-20-2005
Hi all,

I have a page that i need to implement a button that says "Paste to
textbox1", which will paste the text content in clipboard to a textbox
control on postback. How can I get values from the windows clipboard in
asp.net?

Please help, thanks in advance!
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      02-21-2005
This is something you can only do on the client-side using JavaScript.
However, you can emit the required code from ASP.NET.

Here's an example of how you might accomplish it. This will only function in
Internet Explorer.

Private Sub Page_Load(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
btnPaste.Attributes.Add("onclick", _
"PasteIt();return false;")
' btnPaste.Attributes.Add("name", "btnPaste")
Page.RegisterClientScriptBlock("pastroutine", _
"<script>function PasteIt()" & _
"{document.all.TextBox2.focus();" & _
"document.execCommand('paste');}</script>")
End Sub

<asp:button id="btnPaste" runat="server" Text="Paste from
Clipboard"></asp:button></p>
<p>
<asp:textbox id="TextBox2" runat="server"></asp:textbox></p>

More on the use of execCommand here:

http://msdn.microsoft.com/workshop/a...asp?frame=true

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto

"fs" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all,
>
> I have a page that i need to implement a button that says "Paste to
> textbox1", which will paste the text content in clipboard to a textbox
> control on postback. How can I get values from the windows clipboard in
> asp.net?
>
> Please help, thanks in advance!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clipboard - Copy Image To Clipboard Mahsha Javascript 1 06-01-2009 05:06 PM
$clipboard = Gtk::Clipboard.get('PRIMARY')... under windows Dan Bishop Ruby 0 08-26-2008 01:47 PM
clipboard.setContents destroys clipboard.getContents? spunibard@gmail.com Java 2 03-02-2007 07:52 PM
Paste from clipboard when clipboard changes mid script melvynm@gmail.com Javascript 4 12-14-2004 10:59 PM
Using VB.Net or C#, utilizing the clipboard object, how to copy an MS Excel graphic from the clipboard to an image control and obtain its source reference TC ASP .Net 5 09-01-2004 04:49 AM



Advertisments