作者yin6705 (yin6705)
看板C_Sharp
标题Re: [问题] RadioButtonList改变字型颜色
时间Thu Nov 25 14:17:57 2010
※ 引述《testcrack (testcrack)》之铭言:
: RadioButtonList中的ListItem欲改变字型颜色,我的方法是:
: <asp:ListItem Value="E01"><font color =blue>无讯号</font></asp:ListItem>
: <asp:ListItem Value="E02"><font color =red>网路断线</font></asp:ListItem>
: :
: :
: 但是我有做SelectedIndexChanged的事件
: 要取得Text的资料,结果连font的标签都取得
: 请问有什麽比较好的方法可以指定某些ListItem改颜色,而且可取得正确内容
我的方法
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="E01" Text="无讯号" style="color: blue;"></asp:ListItem>
<asp:ListItem Value="E02" Text="网路断线" style="color: red;"></asp:ListItem>
</asp:RadioButtonList>
程式写法(C#)
RadioButtonList1.Items[0].Attributes["style"] = "color:blue";
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.120.159.50
1F:推 testcrack:可是..ListItem没有style的属性.... XD 11/25 16:27
2F:→ yin6705:ListItem是没这个属性,但是可以这样写,你试试看 11/25 16:32
3F:推 testcrack:的确可以,感谢y大。但是VS2005会因非有效属性出现错误, 11/25 18:03
4F:→ testcrack:不过一样可以在浏览器上跑。这样与效能有影响吗? 11/25 18:06
5F:→ yin6705:应该没有影响 11/25 18:31