Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my web application in ASP.net, in a textbox i have written some code on onkeyup() event in javascript..
onkeyup of Textbox1 i have set value of textbox1 in textbox2..
When user type any text in textbox1 value get set in textbox2,
But when user cut or paste (by mouse right click) some text in textbox1 then value in textbox2 is not getting changed..
Thats what i need..
When user cut/paste (by mouse right click) text, that changed text must appear to textbox2..


plz help..
Posted
Updated 24-Mar-14 7:59am
v3
Comments
JoCodes 24-Mar-14 7:26am    
Can you show the code you tried?
Mayuri Gandhi 24-Mar-14 13:55pm    
IN HTML :
<asp:TextBox ID="TextBox_2" runat="server" Style="text-align: right" onkeyup="copy_txt2_to_txt3();" onPaste="copy_txt2_to_txt3();">0.00

<asp:TextBox ID="TextBox_3" runat="server" Style="text-align: right" Width="150px"> 0.00


IN JAVASCRIPT :
function copy_txt2_to_txt3() {
var t_2 = document.getElementById("<%= TextBox_2.ClientID %>");
var t_3 = document.getElementById("<%= TextBox_3.ClientID %>");
if (t_2 != null) {
if (isNaN(t_2.value) || t_2.value.toString().trim().length == 0) {
t_2.value = "0";
}
t_3.value = Math.round(t_2.value);
}
}
Mayuri Gandhi 29-Mar-14 3:42am    
JoCodes Plz help me in following issue..

http://www.codeproject.com/Questions/751673/The-Microsoft-ACE-OLEDB-provider-is-not-registered

Very URGENT..
Plz help..

1 solution

you can call javascript function on events like oncut and onpaste event and write your logic on this function.

JavaScript
function textchange()
{
document.getelementbyid('txt2').text (or may be .value)   = document.getelementbyid('txt1').text ;
}



ASP.NET
<asp:textbox id="txt1" runat="server" oncut="textchange();" onpaste="textchange();" xmlns:asp="#unknown">
<asp:textbox id="txt2" runat="server">
</asp:textbox></asp:textbox>
 
Share this answer
 
Comments
Mayuri Gandhi 24-Mar-14 13:58pm    
Thanks..Bt its not working..
Value before pasting is set.. Instead I want value after paste..
ravikhoda 25-Mar-14 5:50am    
please explain what do you mean by value before pasting is set. is that when you right click on the textbox and do not press paste but still its copy something.... ?
Mayuri Gandhi 25-Mar-14 14:40pm    
It means :
For example I have a Textbox on my form with text 0.00.
Now when I paste some text in this textbox the onPaste event on textbox get fired. In that event when I have taken value in textbox. It gives me 0.00 value instead I want the value which I have pasted in it

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