How to: Set HTML Server Control Properties Programmatically
HTML server controls are of two slightly different types. The HTML elements most commonly used in forms are available as individual HTML server controls, such as, , , and so on. These HTML server controls expose their own, control-specific properties that map directly to HTML attributes. However, any HTML element can be converted to a control. In that case, the element becomes an with base class properties such as TagName, Visible, and InnerHTML.
To set properties of HTML server controls
Get or set the property name as you would with any object. All properties are either strings or integers.
The following example illustrates setting property names:
All HTML server controls also support ancollection, which gives you direct access to all the control's attributes. This is particularly useful for working with attributes that are not exposed as individual properties.
To work with control attributes directly
Use the properties and methods of a control's Attributes collection, such as Add, Remove, Clear, and Count. The Keys property returns a collection containing the names of all the attributes in the control. The following examples show various ways to use the Attributes collection: