Login
Register
Close
Articles
Technology News
All Articles
Submit Guest Post
Tools & Utilities
Code Converter
Forum
Learn
Tutorials
Interview Experience
Practice Tests
Freelancers
Services
Software Development
SEO & Digital Marketing
IT Companies
Login
Register
Articles
Technology News
All Articles
Submit Guest Post
Tools & Utilities
Code Converter
Forum
Learn
Tutorials
Interview Experience
Practice Tests
Freelancers
Services
Software Development
SEO & Digital Marketing
IT Companies
Discussion Forums
.NET
JavaScript
You must
Sign In
to post a response.
Category:
JavaScript
28 Oct 2015 01:47
Anjali
Joined:
12/02/2008
Level:
Silver
Points:
173
Points:
2
Textbox text in clipboard
Hi,
I want to copy my textbox value in clip board. I tried using window.clipboardData.setData(); but it is saying that window.clipboard is undefined. should I include any Js or any supporting files?
#763021
28 Oct 2015 02:58
Nirav Lalan
Joined:
06/04/2012
Level:
Gold
Points:
4230
Points:
4
Hello Anjali,
Refer the below code :
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" BorderStyle="Solid"></asp:TextBox>
<asp:Button ID="ButtonCopy" runat="server" Text="Copy to clipboard"
onclick="ButtonCopy_Click" />
</div>
</form>
</body>
</html>
Code - behind (C#) :
using System.Windows.Forms;
using System.Threading;
void copytoclipboard()
{
if (TextBox1.Text.Length > 0)
{
Clipboard.SetText(TextBox1.Text);
}
}
protected void ButtonCopy_Click(object sender, EventArgs e)
{
Thread myth;
myth = new Thread(new System.Threading.ThreadStart(copytoclipboard));
myth.ApartmentState = ApartmentState.STA;
myth.Start();
}
See the attached image. It's an output i have got using above mentioned code.
Hope this is what you are looking for.
Regards,
Nirav Lalan
DNS Gold Member
"If you can dream it, you can do it."
Delete Attachment
#764146
17 Jan 2016 22:58
shashikant
Joined:
15/12/2015
Level:
Gold
Points:
1308
Points:
3
Hi Anjali,
Yes setData is working with me as follows:
window.clipboardData.setData('Text', 'Textbox text');
But I have following js included in my program:
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js"></script>
Hope this will help you.
Regards,
Shashikant Gurav
shashikantgurav22@gmail.com
Sign In
to post your comments
Submit New Thread
Return to
Return to Discussion Forum
Top Contributors
Today
Last 7 Days
aleena joki
(2)
more...