Click here to Skip to main content
15,886,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have 2 textboxes.

As soon as I write something in one textbox, it should be displayed on the other textbox, as we see in typing master.

How would this happen and on which event of the first textbox the code should be written.

I didn't find any such event.
Posted
Updated 29-Oct-10 2:07am
v2

<script type="text/javascript" language="javascript">
    function test(){
    //alert("test");
    var htText=document.getElementById("TextBox1");
    var seText=document.getElementById("TextBox2");
    seText.value=htText.value;
    }
    </script>


<asp:TextBox ID="TextBox1" runat="server" onkeypress="test()"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
 
Share this answer
 
v2
Comments
Mohd Wasif 29-Oct-10 8:43am    
Many Many Thanks To You.
m@dhu 29-Oct-10 8:49am    
Most welcome.
Hi,

you just need to subscribe to the TextChanged Event of the first text box. Then in the event handler:

private void TextBox1_TextChanged(object sender, EventArgs e)
{
  TextBox2.Text = TextBox1.Text;
}


Alternatively you can use the KeyPress event!
 
Share this answer
 
v2
Comments
Mohd Wasif 29-Oct-10 8:14am    
I did it earlier but as I said as soon as i start entering text in first textbox
thing should be displayed on second textbox

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