Code Snippet posted by:
Chikul | Posted on: 1/30/2010 | Category:
JavaScript Codes | Views: 5228 | Status:
[Member]
|
Alert Moderator
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Copy to ClipBoard and paste from ClipBoard Using JavaScript</title>
<script type="text/javascript">
function CopyToClipboard()
{
var CopiedTxt= document.selection.createRange();
CopiedTxt.execCommand("Copy");
}
function PasteFromClipboard()
{
document.getElementById('txtArea').focus();
var PastedText = document.getElementById('txtArea').createTextRange();
PastedText.execCommand("Paste");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Copy any Text . It will paste in the Text Box." Width="181px"></asp:Label>
<asp:TextBox ID="txtArea" runat="server" Height="34px" Width="319px" TextMode="MultiLine"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnPaste" runat="server" Text="Paste" OnClientClick="PasteFromClipboard()" />
<asp:Button ID="btnCopy" runat="server" Text="Copy" OnClientClick="CopyToClipboard()"/>
</form>
</body>
</html>