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

我想在 aspx.CS 后台中写:this.TextBox1.BackColor = "#006030"; 为什么报错, 可是在aspx 页中就正常啊


我想在   aspx.CS   后台中写:this.TextBox1.BackColor   =     "#006030 ";   为什么报错,   可是在aspx   页中就正常啊

------解决方案--------------------
this.TextBox1.BackColor = System.Drawing.ColorTranslator.FromHtml( "#006030 ");需要一个Color对象
------解决方案--------------------
using System.Drawing;
this.TextBox1.BackColor = ColorTranslator.FromHtml( "#006030 ");
------解决方案--------------------
别忘了引用:System.Drawing