Click here to Skip to main content
14,298,626 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,

I am developing a add entry page which contains lot of textboxes and dropdownlists.
On button click event, I want to copy all the data from textboxes and dropdowns so that next time the user wants to add same data he can click on paste button so all the data which is copied is pasted as it is.
Is it possible to write code on this?????
Posted
Comments
arindamrudra 12-Apr-13 7:02am
   
Write Jquery or Javascript code if you are doing the copy side by side, means one text box contains value and you want the same in the other text box. Or if you want it from the last save of database, fetch and set the value in properties of a class and use the same to populate old data.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

<html><head><script language="JavaScript">

function ClipBoard()
{
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("Copy");
}

</script>
</head>
<body>

<span id="copytext" style="height:150;width:162;background-color:pink">
This text will be copied onto the clipboard when you click the button below. Try it!
</span>

<textarea id="holdtext" style="display:none;">
</textarea>
<button onclick="ClipBoard();">Copy to Clipboard</button> 

</body>
</html>


The above code will copy the value of a span to clipboard .

But as you have mentioned .You have to copy the text of all the controls, you can iterate through all the input controls , find the value / text of each control , store it in some dictionary format , like <controlid,value> . Then on focus of element you can find the value of a specific control from the dictionary , set the text as clipboard text , and when user will press paste , the previous data will be pasted in the input field

Hope that helps.

[ Happy Coding ]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100