asp.net jQuery instance 4 (copy textbox text to local clipboard) _jquery

Source: Internet
Author: User
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/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.