0
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.

4
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by finito
0

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

Edited by farooqaaa: n/a

0

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 .

0

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;
        }
0

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??

0

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

Attachments Screenshot-2.png 113.78 KB
0

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

Attachments screen.jpg 343.39 KB
0

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.

Attachments Screenshot-3.png 105.58 KB
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.