ASP.NET Label Control
The label control is used to output dynamic text to a web page. Much like the <FONT> tag in HTML, you can define
the font-size and font-color and font-family by defining them in a class in your stylesheet then add that class name to the
CssClass property of the label control. Then if you later decide you want to change the appearance simply update your stylesheet.
The text that appears in a label control can be defined in the "code-behind" to
change dynamically. Each label control has an ID property so that you can reference the label in code. So if you have 6 label controls
on a page, you can define in your code what text is to be displayed in each control. Set the text of the label in your "code-behind" to
by defining the id.text = "what you want your text to be." You can also set the property of the the label
to visible="false" if you only want the label to display after some event.
One cool thing about label controls is that you can define a "Tooltip" and this will display in a small
pop-up box when moused over.
Label control with text that changes daily.
The below example demonstrates a label control with dynamic text that changes every day.
Today is:
5/20/2012
ASP.NET
<asp:Label ID="lblMsg" runat="server" Text="" />
VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim DayOfWeek As String = Date.Today()
lblMsg.Text = DayOfWeek
End Sub
ASP.NET
Web Controls
Standard Controls
List Controls
Images & Links
Navigation