Copy Past Clipboard in ASP.net

No.of Views1260
Bookmarked1 times
Downloads 
Votes0
By  usamawahabkhan   On  11 May 2010 08:05:59
Tag : ASP.NET , Miscellaneous
Copy Past Clipboard in ASP.net
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

Copy and Past in Asp.net With the help of javascript its very easy by using Java Clipboard Function and Call from C# or Vb.net and use it
 

To Copy

ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Copy", "clipboardData.setData('text', '" + TextBox1.Text + "');", True)

To Paste

ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Past", "document.getElementById('textbox2').focus();
 PastedText = document.getElementById('textbox2').createTextRange(); PastedText.execCommand('Paste');", True)

The Complete code

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Copy", "clipboardData.setData('text', '" + TextBox1.Text + "');", True)

        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Past", "document.getElementById('textbox2').focus(); 
        ; PastedText = document.getElementById('textbox2').createTextRange(); PastedText.execCommand('Paste');", True)

    End Sub
End Class

Sample Project Source

Download source files -3 kb

 
Sign Up to vote for this article
 
About Author
 
usamawahabkhan
Occupation-Not Provided
Company-Not Provided
Member Type-Senior
Location-Pakistan
Joined date-06 May 2010
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
    Auto Growing TextBox or TextArea in ASP.NET
    Published Date : 08/May/2010
    In this code snippet, you will learn how to bind DropdownList within the ListView in ASP.NET. The ListView is powerful control and fully customizable using templates.
    Published Date : 10/Oct/2010
    In this codesnippet, i will show How to Delete Row in GridView using JQuery in ASP.NET.
    Published Date : 20/Jul/2011
    In this snippet, I will show how to format a cell and apply style in gridview using JQuery. Sometimes we may need to apply the format for a particular cell based on the cell value; it can be done in within DataRowBound event in asp.net.
    Published Date : 05/Jan/2011
    In this snippet I will explain how to add controls dynamically in asp.net and register events for the controls and make it work events perfectly. Last week I have read the forums many readers asking about add controls dynamically in asp.net giving problems and also it not working properly with events
    Published Date : 03/Jan/2011
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top