I have a repeater and inside of it is a textbox that contains my data from the database. Of course at run-time it will generate lots of data meaning lots of textboxes too.
<asp:Repeater ID="rpter" runat="server">
<ItemTemplate>
<fieldset>
<legend>
<asp:Label ID="lblLegend" runat="server" Text='<%#DataBinder.Eval(Container,"DataItem.Name")%>' Font-Bold="true" />
</legend>
<div style="border: single, 1px;">
<div>
<asp:TextBox ID="txtMessage" runat="server" Text='<%#DataBinder.Eval(Container,"DataItem.Message")%>' Width="100%" TextMode="MultiLine"></asp:TextBox>
</div>
<div>
<asp:Button ID="btnCopy" runat="server" Text="Copy" CommandName="Copy" OnClientClick="copyClipboard()" />
</div>
</div>
</fieldset>
</ItemTemplate>
</asp:Repeater>
What I want is to select the text from the textbox besides the copy button when I clicked the button so that I can copy it on clipboard..
function copyClipboard() {
CopiedTxt = document.selection.createRange();
CopiedTxt.execCommand("Copy");
}