Adsence750x90

Friday, May 23, 2008

How to Change Background color of Table Using ASP.NET - server side style changing

How to Change Background color of Table Using ASP.NET

In a ASP.NET Page, we can change the background color by HtmlTextWriterStyle. This specify the HTML Styles available to an System.Web.UI.HtmlTextWriterStyle or System.Web.UI..Html32TextWriterStyle object output stream. You can Find your table using FindControl("string table Name")
then
table.Style.Add(CssStyleCollection); Using this method you can change styles in ypur Page. Using
HtmlTextWriterStyle we can Change background color Dynamically.
C# Code for Change background of table

HtmlTable htmlTable = FindControl("tblmain") as HtmlTable;
htmlTable.Style.Add(HtmlTextWriterStyle.BackgroundImage, "image.jpg");

No comments: