473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Paste from clipboard in asp.net

fs
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!
Nov 19 '05 #1
1 8487
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" <fs@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
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!


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: xyz | last post by:
I have a menu item to handle clipboard actions (cut, copy, paste). When I paste text that I copied from a Hungarian web page, the display looks normal on my RichTextBox, but the text retrieved from...
0
by: 78 | last post by:
Hello, Is there any way to paste clipboard data captured in a VB.NET app to an external program or a field? any help really reallly appreciated 'cause I've searched the 'net for like 20 hours...
0
by: Christopher | last post by:
Hello, First, I appologize for the length but I want to get all the facts down so as not to waste any time :) I'm trying to allow the user of my C# app to copy a DataGrid full of double values...
3
by: Stilgar[bbs.isca.uiowa.edu] | last post by:
Here's my newbie question: I have several VB forms which are all inherit a standard template form that I made. In my template form, I added a menu bar with some generic cut, copy, and paste...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
1
by: pranav.rajyaguru | last post by:
Hi Friends I want to show Clipboard data in image format is it possible to image data in javascript function if it is possible then pls give me solution for that... - Pranav Rajyaguru
11
by: RobKinney1 | last post by:
Hello, I am looking for a clever way to prevent someone from pasting copied text outside of my app. I know how to monitor the clipboard and get an WM_DRAWCLIPBOARD message when text is stored...
17
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have...
1
by: fluxcapacitor | last post by:
I'm developing an application to automate existing software using a combination of SendUserInput P/Invoke calls and various other things, I'm wondering how one goes about pasting the contents of the...
1
by: Figmo | last post by:
Wow.....this is darned odd.... I have an app that integrates with other applications. It registers a global hotkey with Windows. When the hotkey executes it sends a CTRL-C to the active...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.