TableCell Render.
- WebControl, , .
protected override void Render(HtmlTextWriter writer)
{
if (Type == CellType.th)
{
writer.Write(HtmlTextWriter.TagLeftChar + "th");
Attributes.Render(writer);
writer.Write(HtmlTextWriter.TagRightChar);
base.RenderContents(writer);
writer.Write(HtmlTextWriter.EndTagLeftChars + "th" + HtmlTextWriter.TagRightChar);
}
else
base.Render(writer);
}
This solution allows you to inherit one class, not how TableCelland TableHeaderCellif you want to configure them accordingly.
EDIT
The property Typein the statement ifis a custom property of the class in which I added enumto simplify the applicable types.
public enum CellType
{
td,
th
}
private CellType _Type;
public CellType Type
{
get { return _Type; }
set { _Type = value; }
}
MPaul source
share