/    Sign up×
Community /Pin to ProfileBookmark

Javascript function to Copy&Paste from clipboard to Textboxes

Hello all,
I have to write a javascript function that let me Copy&Paste values from the Clipboard to
several textboxex that I have in ASP.NET Datagrid.

In ITemDataBound event I have this code:

private void grdData_ItemDataBound(object sender, DataGridItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
TextBox txtProposta1 = (TextBox)e.Item.FindControl(“txtProposta1”);
TextBox txtProposta2 = (TextBox)e.Item.FindControl(“txtProposta2”);

TextBox txtProposta3 = (TextBox)e.Item.FindControl(“txtProposta3”);
TextBox txtProposta4 = (TextBox)e.Item.FindControl(“txtProposta4”);
TextBox txtProposta5 = (TextBox)e.Item.FindControl(“txtProposta5”);
TextBox txtProposta6 = (TextBox)e.Item.FindControl(“txtProposta6”);
TextBox txtProposta7 = (TextBox)e.Item.FindControl(“txtProposta7”);
// …etc ….

// Eventi
txtProposta1.Attributes.Add(“onpaste”, “return onPaste(this)”);
txtProposta2.Attributes.Add(“onpaste”, “return onPaste(this)”);
// …etc ….

}

so I have to write to this function – onpaste – that copy the values in these textboxes.

This task is row by row, not in group (so it could be more easy to write).

Anyone can help me in this task?

Thanks a lot.

Luigi

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SparoHawkOct 31.2012 — As far as I have read there are restrictions placed on the interaction between JS and the browser's clipboard. As such, most methods you'll find online use a flash file so that it receives a JS command and text so that in turn it can copy it to the clipboard. Why is flash not restricted? No idea, but its not.

Just Google it and you'll find tons of alternatives:

http://www.google.com/search?q=javascript+copy+to+clipboard
Copy linkTweet thisAlerts:
@rnd_meNov 03.2012 — you'll want to cut and paste in one textarea, and break it up into pieces that go in each textbox.
×

Success!

Help @Ciupaz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...