I am creating a textBox within a repeater like this ( so there are many textboxes created inside a loop and added to the repeater control)
.aspx.cs
TextBox textBox = new TextBox();
textBox.TextChanged += new EventHandler(textBox_TextChanged);
and I have a function like this for changing the textBox background color to white if that textbox has some text(it is yellow on creation of the form)
protected void textBox_TextChanged(object sender, EventArgs e)
{
TextBox textBox = sender as TextBox;
if (textBox.Text != String.Empty)
{
textBox.BackColor = System.Drawing.Color.White;
}
}
but the function doesn’t seem to be hit at all. Any pointers on what I am doing wrong?
Thanks.
I would suggest to save the round trip to the server and do it with javascript. When you create your control in the code behind add the onchange client event attribute and handle it:
Hope it helps!