As a mark, attribute settings will be frequently used in the future.
You can set web server control properties by programming to change the control's appearance and behavior at runtime.
The following describes how to set different attribute types:
1. Set Properties Based on Single value or enumeration:
If the data type of the Web server control property is basic (string, Boolean, or numeric), you only need to specify it to the property to set the corresponding property value. Similarly, if the attribute value is defined in the enumeration class, you can only specify this enumeration to the attribute.
1.1 set single-value-based Attribute values
■ Specify this value as a text or variable, as shown in the following example:
Label1.text = "hello ";
Datagrid1.pagesize = 5;
■Set enumeration-based Attribute values
// Uses textboxmode Enumeration
This. textbox1.textmode = textboxmode. singleline;
// Uses imagealign Enumeration
This. image1.imagealign = imagealign. Middle;
2. Set Unit attributes:
The width, height, and similarity attributes are set in units. The Unit is implemented as an object (unit structure). You can specify the value and measurement unit in multiple ways.
2.1Set unit-based attributes
// Default is pixels.
Textbox1.width = new unit (100 );
Textbox1.width = new unit (100, unittype. pixel );
Textbox1.width = new unit ("100px ");
// Centimeters
Textbox1.width = new units ("2 cm ");
Textbox1.width = new Unit (10, unittype. Percentage );
Textbox1.width = new units ("10% ");
3. Set the color attribute
To set the color (for exampleBackcolorAttribute.ColorObject reference.
Button1.backcolor = color. fromname ("red ");