dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Javascript function to Copy&Paste from clipboard to Textboxes

  1. #1
    Join Date
    Apr 2009
    Posts
    4

    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

  2. #2
    Join Date
    Jul 2007
    Posts
    386
    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=javas...y+to+clipboard

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    you'll want to cut and paste in one textarea, and break it up into pieces that go in each textbox.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles