In this section, we'll see how to copy the contents of the multiline text box to the Clipboard.
Note: jQuery Clipboard plugin only supports IE
Interface code:
Copy Code code as follows:
<form id= "Form1" runat= "Server" >
<div align= "center" >
<fieldset style= "width:400px; height:300px; " >
<p> Please input your comments:</p>
<asp:textbox id= "txtcomment" textmode= "MultiLine" rows= "5" width= "300px" height= "200px"
runat= "Server" ></asp:TextBox>
<br/>
<asp:hyperlink id= "Lnkhighlight" text= "Click to copy Comment" runat= "server" ></asp:HyperLink>
</fieldset>
</div>
</form>
Display interface:
Script section:
Copy Code code as follows:
<script src= "Scripts/jquery-1.4.1-vsdoc.js" type= "Text/javascript" ></script>
<script src= "Scripts/jquery.clipboard.js" type= "Text/javascript" ></script>
<style type= "Text/css" >
A
{
Color: #0000FF;
Cursor:pointer;
}
</style>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$.clipboardready (function () {
$ ("a"). Click (function () {
$ ("#<%=txtcomment.clientid%>"). Select ();
$.clipboard ($ ("#<%=txtcomment.clientid%>"). Val ());
});
});
});
</script>
After adding the script, click the Copy button to display the results as follows:
Open Notepad Press CTRL + V:
Haha success, it is so simple.
Plugin Download Address: Http://plugins.jquery.com/project/clipboard
There is also a zero clipboard plug-in to support Cross-browser, it is implemented through a Flash file and Javascirpt interface, for more information, please visit http://code.google.com/p/zeroclipboard/