O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.19. Programming Web Server Controls

All the control properties we've set interactively in the Properties window while using the Web Forms designer, such as ForeColor or input Mode for a TextBox, can also be set within our program. For example, to dynamically reset the Mode, Width, and ForeColor of a TextBox, we would write the following,

TextBox1.Mode = TextBoxMode.SingleLine;
TextBox1.Width = new Unit( 200, UnitType.Pixel );
TextBox1.ForeColor = Color.Red;

where TextBoxMode and UnitType are enumeration types of alternative property values, and Red is a static property of the Color class.

Color provides many named colors, such as Black, Blue, BlanchedAlmond, and BurlyWood.

In addition to changing the properties of an existing control, we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required