Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
How to preview data of one text box in another text box while still writing, i use Array but didn't works for me any help?

<pre lang="HTML">
<table>
<tr><td>
<asp:Label Id="Question" Text="Question:" runat="server"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="QuestionTextBox" runat="server" />
</td></tr>

<tr><td>
<asp:Label ID="tag" Text="Tag:" runat="server" />
<asp:TextBox ID="tabTextBox" runat="server" Width="550px"/>
</td></tr>
<tr><td>
<asp:TextBox ID="explain" runat="server" Height="377px" Width="673px" onkeypress="document.getElementById('PreviewTextBox').value = document.getElementById('explain').value" TextMode="MultiLine" AutoPostBack="true" />
</td></tr>
<tr><td>
<asp:Label ID="preview" Text="Preview" runat="server"/>
</td></tr>
<tr><td>
<asp:TextBox runat="server" Height="300px" Width="673px"
ReadOnly="false" ID="PreviewTextBox"
ontextchanged="PreviewTextBox_TextChanged" BackColor="#F2F2F2"
TextMode="MultiLine" AutoPostBack="true"/>
</td></tr>
</table>
</pre>



This is the code i have tried but didn't help.
Posted
Updated 25-Sep-11 19:53pm
v2
Comments
André Kraak 22-Sep-11 15:51pm    
Please share any relevant code with us, seeing the code might us help understand the problem your are facing.

If you wish to change your question use the Improve Question button.
Asad_Iqbal 22-Sep-11 23:45pm    
private void txtbox1_KeyUp(object sender, KeyEventArgs e)
{
txtbox2.Text = txtbox1.Text;
}


it is just like this but i want the as i start writing text that text is also written in preview text box.

use TextBox TextChanged event.
 
Share this answer
 
Comments
Asad_Iqbal 22-Sep-11 17:19pm    
Try that doesn't work friend.
You try this code its work...

Using javascript in aspx page

XML
<asp:TextBox ID="TextBox1" runat="server" onkeyup="document.getElementById('TextBox2').value = document.getElementById('TextBox1').value"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>


or

Enable Autopostback property is true then write this code in codebehind

TextChageEevent

textbox2.text=textbox1.text;


Happy coding....
 
Share this answer
 
Comments
Asad_Iqbal 22-Sep-11 23:47pm    
Your code works but i want that when i start writing in first textbox it also start written automatically in another textbox as same as when we write question in code project.
rkthiyagarajan 22-Sep-11 23:53pm    
Use onkeypress event.
Asad_Iqbal 23-Sep-11 3:25am    
Sorry to disappoint you bro but didn't work that too, i don't know what to do?
rkthiyagarajan 23-Sep-11 3:39am    
Hello Bro.. which code you try? i gave same as codeproject. You use this

<asp:TextBox ID="TextBox1" runat="server" onkeyup="document.getElementById('TextBox2').value = document.getElementById('TextBox1').value">
<asp:TextBox ID="TextBox2" runat="server">
Asad_Iqbal 23-Sep-11 7:50am    
the one below let me try upper will see it works or not but thx for replying i let u know it its done
On TextChageEevent
textbox1.text=textbox2.text;
 
Share this answer
 
Comments
Asad_Iqbal 22-Sep-11 17:19pm    
Try that doesn't work friend.
private void txtbox1_KeyUp(object sender, KeyEventArgs e)
{
txtbox2.Text = txtbox1.Text;
}
 
Share this answer
 
Comments
Asad_Iqbal 22-Sep-11 17:19pm    
Try that doesn't work friend.
Asad_Iqbal 22-Sep-11 23:47pm    
Your code works but i want that when i start writing in first textbox it also start written automatically in another textbox as same as when we write question in code project.

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