Hi,
I using GridView with TextBox controls.
I need click on the button to copy the text from the text field and paste the text (e.g. ctrl+v) using C# ASPNET
This is the tutorial
I don't have error but the copy not working.
Help me to do it.
My code below
<script type="text/javascript">
function myFunction() {
/* Get the text field */
var copyText = document.getElementById("txcp");
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
alert("Copied the text: " + copyText.value);
}
</script>
<asp:TemplateField HeaderText="Annotation" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:TextBox ID="txcp" runat="server"
Width="100%" TextMode="MultiLine"
ClientID="txcp" ClientIDMode="Static"
Text='<%# Eval("tAnnotation").ToString() %>'
CssClass="ddl_Class_new"></asp:TextBox>
<asp:Button ID="btncopy" runat="server" Text="Copy text" OnClientClick="myFunction();" />
</ItemTemplate>
</asp:TemplateField>