I'm trying to change the color of a text in a label per condition.
I have tried the following option but none of them works:
if (gameNameTXT.Text != "")
{
pubName.ForeColor = System.Drawing.Color.Green;
pubName.ForeColor = System.Drawing.Color.FromArgb(11, 102, 35);
pubName.Attributes.CssStyle.Add("color", "green");
}
(pubName
in the ID of the label)
I have located the snipped code in the Page_Load
section and/or the Page_Init
section.
What I want is that the color of the text changes to green if the user wrote something in the text box.