In my previous post I have explained How to create XML SiteMap Dynamically in ASP.Net. Today I will explain How to Copy the Text of a textbox to Clipboard?. It is very simple. You can do it using JavaScript or Jquery.
Step 1: Add below code to your design page.
- <p id="p1" style="display:none"></p>
- <asp:TextBox ID="txtReferalLink" runat="server" CssClass="form-control"></asp:TextBox><span><a onclick="copyToClipboard('#p1')" href="javascript:void(0);" class="btn btn-info">Copy Url</a></span>
Step 2: Add the below code inside the page header.
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
- <script>
- function copyToClipboard(element) {
- var controlValue = document.getElementById('<%=txtReferalLink.ClientID%>').value;
- document.getElementById('p1').innerHTML = controlValue;
- var $temp = $("<input>");
- $("body").append($temp);
- $temp.val($(element).text()).select();
- document.execCommand("copy");
- $temp.remove();
- alert('Url has copied');
- }
- </script>
Great
ReplyDeleteHow To Copy The Text Of A Textbox To Clipboard? - Asp Tanmoy >>>>> Download Now
ReplyDelete>>>>> Download Full
How To Copy The Text Of A Textbox To Clipboard? - Asp Tanmoy >>>>> Download LINK
>>>>> Download Now
How To Copy The Text Of A Textbox To Clipboard? - Asp Tanmoy >>>>> Download Full
>>>>> Download LINK