Find control on form and set value using C#

 

Used
Microsoft Visual studio 8 with .net 3.5

The Form

Create a form with:

1 x TextBox name the TextBox id "TextBox1"
1 x Button

The Code
In the button click procedure place the following code.
            TextBox control = (TextBox)this.FindControl("TextBox1");
            if (control != null)
            {
                control.Text = "found control!";
                control.BackColor = System.Drawing.Color.DarkRed;
            }
When the click procedure has found the TextBox the Text value will be changed and the BackColor will be set.
 
www.programmingsystems.eu