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

Get C# Primer: A Practical Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.