Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

HTML
<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 ]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900