日期:2014-05-18  浏览次数:20427 次

请教:htmltablecell 怎样设置背景色?
我这样写不对:
c1.innerhtml="<img src='images/a.gif' bgcolor='#009900'>"
请问该怎样写?

------解决方案--------------------
C# code
c1.BgColor = "#009900";

------解决方案--------------------

HtmlTable ht = new HtmlTable();
HtmlTableCell tc = new HtmlTableCell();
HtmlTableRow tr = new HtmlTableRow();
tc.InnerHtml = "TableCell";
tc.Style.Add("bgcolor", "#009900");
tc.Style.Add("background-image", "images/a.gif");
tr.Controls.Add(tc);
ht.Rows.Add(tr);
ph.Controls.Add(ht);
------解决方案--------------------
背景图还是色???

C# code
HtmlTable ht = new HtmlTable();
        HtmlTableRow htr = new HtmlTableRow();
        HtmlTableCell htc = new HtmlTableCell();
        htc.Width = "200px";
        htc.Height = "50px";
        htc.InnerText = "alsdjflsdjf";
        htc.BgColor = "#ff0000";
        htr.Cells.Add(htc);
        ht.Rows.Add(htr);
        this.Controls.Add(ht);

------解决方案--------------------

tc.Style.Add("background-color", "#FF0000");
tc.Style.Add("background-image", "images/a.gif"); 


这样可以的。
------解决方案--------------------
探讨

HtmlTable ht = new HtmlTable();
HtmlTableCell tc = new HtmlTableCell();
HtmlTableRow tr = new HtmlTableRow();
tc.InnerHtml = "TableCell";
tc.Style.Add("bgcolor", "#009900");
tc.Style.Add("background-image", "images/a.gif");
tr.Controls.Add(tc);
ht.Rows.Add(tr);
ph.Controls.Add(ht);