怎么改变label的颜色啊

matengsos 2012-08-29 11:34:02
哥们用这个不行
Label9.BackColor = Color.Red;
enable为true;大家给点意见啊
...全文
2480 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
SallyAngela 2012-09-01
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
//方法一
this.Label9.ForeColor = System.Drawing.Color.Red;

//方法二
this.Label9.Style.Add(HtmlTextWriterStyle.Color, "red");

//方法三
this.Label9.Style.Add("color", "red");
[/Quote]

方法一是设置label标签的前景色为红色
方法二和三是设置文本样式为红色
pengxiaoshuang0 2012-08-30
  • 打赏
  • 举报
回复
this.Label9.ForeColor = "red" 字体色

Label9.BackColor = "red"; 背景色
Dotar 2012-08-30
  • 打赏
  • 举报
回复
这个帖回复是不是有点多了。。。。。。。
CqCoder 2012-08-30
  • 打赏
  • 举报
回复

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>

<script>
function changeBackColor()
{

document.getElementById('<%=Label9.ClientID%>').style.backgroundColor="red";

}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label9" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="changeBackColor(); return false;"
OnClick="Button1_Click" />
</div>
</form>
</body>
</html>

wfl258 2012-08-30
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 的回复:]
引用 4 楼 的回复:

请问一下,你是要实现Lable标签的背景颜色的设置吗?如果是,可以这样写:
this.Label9.BackColor=System.Drawing.Color.Red;
如果是标签的字体颜色则可以用:
Label9.ForeColor = System.Drawing.Color.Blue;
不知道你是不是需要这样的效果?
[/Quote]
我同意
siwanglongjuan 2012-08-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

请问一下,你是要实现Lable标签的背景颜色的设置吗?如果是,可以这样写:
this.Label9.BackColor=System.Drawing.Color.Red;
如果是标签的字体颜色则可以用:
Label9.ForeColor = System.Drawing.Color.Blue;
不知道你是不是需要这样的效果?
[/Quote]

+1
格桑花 2012-08-30
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
//方法一
this.Label9.ForeColor = System.Drawing.Color.Red;

//方法二
this.Label9.Style.Add(HtmlTextWriterStyle.Color, "red");

//方法三
this.Label9.Style.Add("color", "red");
[/Quote]


+++++++
H_Gragon 2012-08-30
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
//方法一
this.Label9.ForeColor = System.Drawing.Color.Red;

//方法二
this.Label9.Style.Add(HtmlTextWriterStyle.Color, "red");

//方法三
this.Label9.Style.Add("color", "red");
[/Quote]
同意!~
laoyingisme 2012-08-30
  • 打赏
  • 举报
回复
外面加个DIV,然后设置DIV也行
yangxxxxxx66 2012-08-30
  • 打赏
  • 举报
回复
还可以在前台设定:
Style="color:red"
太极厨师 2012-08-30
  • 打赏
  • 举报
回复
学习了 刚好被我找到了
wangyizhi58 2012-08-30
  • 打赏
  • 举报
回复

+1[Quote=引用 13 楼 的回复:]

HTML code

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>

<script>
function changeBackColor()
{

document.getElementById('<%=Label9.Client……
[/Quote]
vocational110 2012-08-30
  • 打赏
  • 举报
回复
up[Quote=引用 1 楼 的回复:]
可以的:引用using System.Drawing;了吗
Label9.BackColor = Color.Red;
[/Quote]
杰拉尔 2012-08-29
  • 打赏
  • 举报
回复
this.Label9.ForeColor = "red" 字体色

Label9.BackColor = "red"; 背景色
qinMengxing 2012-08-29
  • 打赏
  • 举报
回复
请问一下,你是要实现Lable标签的背景颜色的设置吗?如果是,可以这样写:
this.Label9.BackColor=System.Drawing.Color.Red;
如果是标签的字体颜色则可以用:
Label9.ForeColor = System.Drawing.Color.Blue;
不知道你是不是需要这样的效果?
fbinger 2012-08-29
  • 打赏
  • 举报
回复
Label1.BackColor = System.Drawing.Color.Red;
Label的BackColor属性是System.Drawing.Color型的
暖枫无敌 2012-08-29
  • 打赏
  • 举报
回复
//方法一
this.Label9.ForeColor = System.Drawing.Color.Red;

//方法二
this.Label9.Style.Add(HtmlTextWriterStyle.Color, "red");

//方法三
this.Label9.Style.Add("color", "red");
  • 打赏
  • 举报
回复
可以的:引用using System.Drawing;了吗
Label9.BackColor = Color.Red;

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧