0

it is such that I have a textbox where I have some content in, and when I click the button clicks then it copies the content that is in textbox by itself, it should not be such that you have to run your mouse over to copy it. it just has to be like that when you click on the button that copies the it themselves.

i have try its here:

<asp:TextBox ID="TextBoxHenvis" CssClass="form-control input-lg" runat="server" ReadOnly="true"></asp:TextBox><br />
            <asp:Button ID="ButtonKopier" runat="server" Text="Kopier Link" OnClientClick="CopyToClipboard()" CssClass="btn btn-success" />

javascript here

function CopyToClipboard() 
    { 
        var controlValue  = document.getElementById('<%=TextBoxHenvis.ClientID%>').value;
        alert(controlValue);
    }

This means in other words that it should download content and so when you click ctrl + v then throw the content into which you got by click button.

  • possible duplicate of [How do I copy to the clipboard in JavaScript?](http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript) – Patrick Evans May 11 '15 at 21:38

1 Answers1

0
function CopyToClipboard() {
    holdtext.innerText = copytext.innerText;
    Copied = holdtext.createTextRange();
    Copied.execCommand("Copy");
}
Sterling Silver
  • 243
  • 1
  • 13