Hi friends,in this article I will explain about jQuery:Copy and Paste User Selected Text in ASP.NET.
I already explained in the previous articles about JQuery:Select Multiple records in GridView with Ctrl Key in ASP.NET using C#/VB.NET,TextBox AutoComplete using JQuery or JSON in ASP.NET and How to get the Month Names in DropDownList in ASP.NET
ASP.NET:
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<head>
<title>jQuery:Copy
and Paste User Selected Text in ASP.NET </title>
<script src="//code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var copied = '';
$("#btnPaste").click(function () {
$("#txtCopied").text(copied);
});
$("#btnCopy").click(function () {
copied =
selectedText.Selector.getSelected();
});
});
if (!window.selectedText) {
selectedText = {};
}
selectedText.Selector
= {};
selectedText.Selector.getSelected
= function () {
var t = '';
if (window.getSelection) {
t =
window.getSelection();
} else if
(document.selection) {
t =
document.selection.createRange().text;
} else if (document.getSelection) {
t =
document.getSelection();
}
return t;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h4 style="color: Green">
Select some text on the page ...</h4>
<p>
ASP.NET,VB.NET,C#.NET,SQL Server,JavaScript,JQuery</p>
<p>
Angular JS,MVC,Web
Services,WCF,WPF,AJAX,XML,HTML</p>
<p>
ASP.NET,VB.NET,C#.NET,SQL Server,JavaScript,JQuery</p>
<p>
Angular JS,MVC,Web
Services,WCF,WPF,AJAX,XML,HTML</p>
<input type="button" id="btnCopy" name="btnCopy" value="Copy" />
<input type="button" id="btnPaste" name="btnPaste" value="Paste" /><br />
<asp:TextBox ID="txtCopied" runat="server" TextMode="MultiLine" Width="150px" Height="100px"></asp:TextBox>
</form>
</body>
</html>
|
The output of the above code as shown in the below figure.
You can download the code by clicking on the below Download image.
Previous Article>>Select Multiple records in GridView with Ctrl Key
"If you like my blog or articles, you can appreciate by leaving your comments or Liking my Facebook pageAspdotnet-kishore, following on Google+ Aspdotnet-Kishore, Twitter on AspdotnetKishore, Linked in Aspdotnet-Kishore, stumbling my posts on stumble upon and subscribing on RSSfeed Aspdotnet-Kishore for free updates directly to your Email inbox . Watch my blog for more articles."
No comments:
Post a Comment