且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Asp.net代码中设置ForeColor

更新时间:2022-11-06 16:33:29

如果您需要更改文本框的文本颜色,那么您可以使用...

If you need to change text color of a textbox then you can use like..
textbox1.ForeColor = Color.White;



或者,如果是标签..


or,in case a label..

Label1.ForeColor = System.Drawing.Color.White;



一个很好的例子是..

http://asp-net-example.blogspot.com/ 2009/03 / how-to-set-change-label-forecolor-font.html [ ^ ]


尝试:

Try:
<span class="style3" style="background-color:#0066FF;color:#FFFFFF;"> {4} </span>





如果没有工作,然后还有一些其他样式表值覆盖你的文本框颜色 - 如果我们看不到你的代码就很难解决。



If that doesn''t work, then there''s some other stylesheet value overriding your textbox color - which is very difficult to solve if we can''t see your code.


尝试这个应该工作:



Try this this should work:

trStudData = strStudData + string.Format("<img src='images/{0}.jpg' width='150' height='41' align='absmiddle' /> {1} {2} {3} <span class='style3' style='background-color:#0066FF;color:White;'> {4} </span> ", readStud.Rows[i][4].ToString().Trim(), readStud.Rows[i][0].ToString(), readStud.Rows[i][1].ToString(), readStud.Rows[i][2].ToString(), readStud.Rows[i][3].ToString());





Sreekanth



Sreekanth