Binding text box with another textbox
I am using two textbox in my application and i want to set the value of textbox2 if i am writing anything in textbox1. the value of textbox1 also display in textbox2. what kind of binding useful for this and what is the code of binding textbox1 with textbox2
Satyapriya NayakPosted Mar 24, 2012, 7:33 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox2.Text=textBox1.Text;
}
}
}
Thanks
SenthilkumarPosted Mar 25, 2012, 12:45 AM
Consider there are two textbox control.
If you have not server side logic then i suggest you to achieve in client side.
In javascript,
function BindValue()
{
if(document.getElementById('txtbox1') && document.getElementById('txtbox2') )
{
document.getElementBy('txtbox2').value = document.getElementById('txtbox1').value;
}
return false;
}
This will bind the value when ever you type something in textbox1 will reflect immediately in textbox2.
Arvind YadavPosted Mar 24, 2012, 8:24 AM