Label server control’s BackColor property get or set the background color of label control. the BackColor property value type is System.Drawing.Color.
This ‘Color‘ represents the background color of label control.
We can simply input any valid color name for BackColor property value such as Magenta, Yellow, Pink etc.
We need to import the System.Drawing namespace to apply label background color programmatically.
The following c# example code demonstrate us how can we apply label background color dynamically at run time in a C# Windws Form Application.
C# Code:
1 2 3 4 5 6 7 8 9 10 | protected void Button1_Click(object sender, System.EventArgs e) { Label1.BackColor = System.Drawing.Color.LightGreen; } protected void Button2_Click(object sender, System.EventArgs e) { Label1.BackColor = System.Drawing.Color.SkyBlue; } |
Output: