protected override void OnInit(EventArgs e)
    {
        this.currency_txt.TextChanged += new EventHandler(currency_txt_TextChanged);
        base.OnInit(e);
    }

    protected void currency_txt_TextChanged(object sender, EventArgs e)
    {
        rateSymbol.Text = currency_txt.Text;
        amountSymbol.Text = currency_txt.Text;
    }

i'm trying to write a textbox text to a label, the above code doesn't change anything or give any errors. My textbox and label are on different tables on the same page.

Try putting MessageBox.Show("Is this event even fired?"); to see if the event is fired or not.

If the MessageBox is not shown then try copying this.currency_txt.TextChanged += new EventHandler(currency_txt_TextChanged); code to public Form1() { ...(here)... }.

Thanks

Hello,
just want to add my 2 cents :)
As farooqaaa said, you should test if your events are fired. If they're fired, but display still won't update, try to call Application.DoEvents Method to force events processing.

One more way achieve that functionality can be using of DataBinding .

you need to use the Leave event. Works much better.

private void currency_txt_Leave(object sender, EventArgs e)
        {
                
               rateSymbol.Text = currency_txt.Text;

               amountSymbol.Text = currency_txt.Text;
        }

Thanks for all the replies, the MessageBox does not return that the event is firing.

How would I connect the TextBox to the Leave method??

Thanks for all the replies, the MessageBox does not return that the event is firing.

How would I connect the TextBox to the Leave method??

Right Click -> Properties -> Events -> Double Click on Leave.

Check attachment

That's what I thought, but I don't have all of those events: I've only got these

That's what I thought, but I don't have all of those events: I've only got these

Jelly I need you to make

AutoPostBack=True for:

rateSymbol
amountSymbol

As soon as you lose focus they will be updated.

You should have said u were using ASP.net

Btw keep your original code.

Please mark as solved.

if solved please mark as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.