Hey guys,
How do you set the forecolor of a label progmatically???

For an ASP label in c# code?

Drop a label in the designer:

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Assign a forecolor in code:

protected void Page_Load(object sender, EventArgs e)
    {
      Label1.ForeColor = System.Drawing.Color.Red;
    }
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

[B]//Reference for setting  color
using System.Drawing;[/B]

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
[B]        Label1.ForeColor = Color.Yellow ;
        Label1.BackColor = Color.Black ;[/B]
    }
}

Hey guys,
How do you set the forecolor of a label progmatically???

Use the following code to change the color of a label

Label1.ForeColor = Drawing.Color.Red
This question has already been answered. Start a new discussion instead.