作者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
推 testcrack:可是..ListItem沒有style的屬性.... XD 11/25 16:27
→ yin6705:ListItem是沒這個屬性,但是可以這樣寫,你試試看 11/25 16:32
推 testcrack:的確可以,感謝y大。但是VS2005會因非有效屬性出現錯誤, 11/25 18:03
→ testcrack:不過一樣可以在瀏覽器上跑。這樣與效能有影響嗎? 11/25 18:06
→ yin6705:應該沒有影響 11/25 18:31