How to Add CSS Styles to ASP.NET Controls from Server Side

Waqas Anwar
29 November 2010
8380 Views

You want to add CSS styles to ASP.NET controls from server side programmatically, you can use Style property available to all ASP.NET server controls.

TextBox1.Style.Add("border", "solid 2px blue");
TextBox1.Style.Add("background-color", "yellow");

TextBox2.Style.Add("font-weight", "bold");
TextBox2.Style.Add("color", "#336699");