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


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");

 

 

About author


User avatar

Waqas Anwar

Founder of EzzyLearning.com, Senior Consultant, Microsoft .NET and Web Technologies

Comments