Dynamically add Style for ASP.NET Controls

we can add style for ASP.Net controls like label,textbox,linkbutton etc
in asp.net there is some enum class HtmlTextWriterStyle using this class we can add style dynamically in asp.Net Controls
HtmlTextWriterStyle:Specifies the HTML styles available to an System.Web.UI.HtmlTextWriter or
System.Web.UI.Html32TextWriter object output stream

lbtnTestButton.Style.Add(HtmlTextWriterStyle.TextDecoration, "none");
lbtnTestButton.Style.Add(HtmlTextWriterStyle.Color, "Red");
lbtnTestButton.Style.Add(HtmlTextWriterStyle.FontSize, "14pt");
lbtnTestButton.Style.Add(HtmlTextWriterStyle.Cursor, "move");
lbtnTestButton.Style.Add(HtmlTextWriterStyle.BorderColor, "Black");
lbtnTestButton.Style.Add(HtmlTextWriterStyle.BorderStyle, "Solid");
lbtnTestButton.Style.Add(HtmlTextWriterStyle.BorderWidth, "2");


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: