Table needs to be a server control… so that you can change its properties programaticaly. Must have an ID attribute be marked with runat=“server”
You can use the Table Web Server Control (System.Web.UI.WebControls.Table) or the Html Server control (System.Web.UI.HtmlControls.HtmlTable).
for the first you can just change its CssClass string property…
Table1.CssClass = “myCssClass”;
for the Html Control you have to add an attribute to the attributes collection.
You don’t have a direct property for Css Classes like the Table Web Server Control.
first clear the attribute class and then add a new attribute.
[size=2]Table1.Attributes.Remove(“class”[size=2]);
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace tabs
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Table Table1;
void Page_Load(Object Sender, EventArgs e)
{
//Table1.CssClass = "";
Table1.Attributes.Remove("class");
Table1.Attributes.Add("class", "csstest");
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
}