ASP. NET jQuery instance 4 (copy the text of TextBox to the local clipboard)

Source: Internet
Author: User

In this section, we will see how to copy the content of the multi-line text box to the clipboard.
Note: jQuery clipboard plugin only supports IE

Interface code:Copy codeThe Code is as follows: <form id = "form1" runat = "server">
<Div align = "center">
<Fieldset style = "width: 400px; height: 300px;">
<P> enter your comment: </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 comments" runat = "server"> </asp: HyperLink>
</Fieldset>
</Div>
</Form>

Display interface:

Script:Copy codeThe Code is 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 Copy to display the following results:

Press Ctrl + V to open notepad:

Haha is successful, that's easy.
Plug-in: http://plugins.jquery.com/project/clipboard
In addition, there is a Zero clipboard plug-in that supports cross-browser, it is implemented through a flash file and the 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.