It is txtName.BackColor = System.Drawing.Color.Red;
one can also use txtName.BackColor = Color.Aqua;
which is the same as txtName.BackColor = System.Color.Aqua;
Only Problem with System.color is that it does not contain a definition for some basic colors especially white, which is important cause usually textboxes are white;
In WinForms and WebForms you can do:
txtName.BackColor = Color.Aqua;
Setting textbox backgroundcolor with multiple colors on single click.
Note:- using HTML and Javscript.
< input id="ClickMe_btn" onclick="setInterval(function () { ab() }, 3000);" type="button" value="ClickMe" />
var arr, i = 0; arr = ["Red", "Blue", "Green", " Orange ", "Purple", "Yellow", "Brown", "Lime", "Grey"]; // We provide array as input.
function ab()
{ document.getElementById("Text").style.backgroundColor = arr[i];
window.alert(arr[i]);
i++;
}
Note: You can change milliseconds, with setInterval 2nd parameter.
webforms;
TextBox.Background = System.Drawing.Color.Red;
in web application in .cs page
txtbox.Style.Add("background-color","black");
in css specify it by using backcolor property
Source: Stackoverflow.com