I have a css file named tablecellmembers.css (and is not yet linked in the .aspx file?) that contains:
td {
border-collapse: collapse;
border-top: thick;
border-top-width: 5px;
border-top-color: blue;
}
Then I created a table, table row, and table cell dynamically in the .cs file.
TableCell tc = new TableCell();
How can I apply that css file to my table cells?
I have tried:
tc.CssClass = "td";
tc.Attributes.Add("tablecellmembers", "td");
But the css is not being applied to the cells..
Add a
linktag to the<head>of your ASPX page (or master page if you’re using one) like so:You don’t need to use CssClass or add any attributes as
tdis an element rather than a class. I recommend you read up on CSS selectors to clarify this.In a nutshell, for the following element:
The following could be used in CSS to refer to it:
td { ... }would apply to all<td>elements#someID { ... }applies to just the element with the id “someID”.someclass { ... }applies to all elements (td or otherwise) with the class “someclass”