Setting properties on server controls is as simple as declaring attributes when writing standard HTML. In fact, for HTML server controls, all attributes supported for an HTML element are treated as properties on a control.
The Web Forms page framework defines properties for specific controls. These can be declared in the same way as HTML attributes. These can also be changed dynamically when a page is loaded or in response to user input.
In the following example, the font-size
, font-bold
, and forecolor
properties of the Label control are set declaratively.
<asp:label id="Message1" font-size="16" font-bold="true" forecolor="red" runat=server>This is Message One</asp:label>
This declarative method of setting property values also works for HTML Controls. In the following example, the src
, alt
, and align
properties are set on this HtmlImage control.
<img id="image1" src="blank.jpg" alt="This is a blank image." align="right" runat="server">
See Also