How to: Set Web Server Control Properties Based on Simple Values or Enumerations
If a Web server control property's data type is a primitive type, such as a String, Boolean, or numeric type, you can set the property value by simply assigning it to the property. Similarly, if the property's values are defined in an enumeration class, you can simply assign the enumeration to the property.
To set a property value based on simple values
Assign the value as a literal or variable, as in the following example:
Label1.Text = "Hello" Datagrid1.PageSize = 5
Label1.Text = "Hello"; DataGrid1.PageSize = 5;
To set a property value based on an enumeration
Assign the value using one of the enumeration values. ASP.NET can resolve the enumeration based on the property's type. The following code example illustrates setting a property using an enumeration:
'Uses TextBoxMode enumeration TextBox1.TextMode = TextBoxMode.SingleLine 'Uses ImageAlign enumeration Image1.ImageAlign = ImageAlign.Middle
// Uses TextBoxMode enumeration TextBox1.TextMode = TextBoxMode.SingleLine; // Uses ImageAlign enumeration Image1.ImageAlign = ImageAlign.Middle;
See Also
Tasks
How to: Set HTML Server Control Properties Programmatically