Ideally Label control is used to place a static, non clickable (can't fire onclick event) piece of text on
the page. When it is rendered on the page, it is implemented through <span></span> HTML tag.
Its properties like
BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc.
are implemented through style properites of <span>.
You can set its Text property either by setting Text properties in the .aspx page or from server side page. (other properties can also be set from both pages)
Following are few properties of the Label that are very useful.
EnableViewState |
true/false. If false ViewState will not be maintained.
|
Visible |
true/false. If false control will not be rendered to the page
|
There is one very important but rarely used properties of Label control is
AssociatedControlID that is used to associate a Label with a particular Control. Like in this example,
Click anywhere in the page except "Write something into the TextBox" in the demo box then click "Write something into the TextBox" and notice that Cursor is placed in the TextBox.