Re: [問題] RadioButtonList改變字型顏色

看板C_Sharp作者 (yin6705)時間15年前 (2010/11/25 14:18), 編輯推噓2(203)
留言5則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《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

11/25 16:27, , 1F
可是..ListItem沒有style的屬性.... XD
11/25 16:27, 1F

11/25 16:32, , 2F
ListItem是沒這個屬性,但是可以這樣寫,你試試看
11/25 16:32, 2F

11/25 18:03, , 3F
的確可以,感謝y大。但是VS2005會因非有效屬性出現錯誤,
11/25 18:03, 3F

11/25 18:06, , 4F
不過一樣可以在瀏覽器上跑。這樣與效能有影響嗎?
11/25 18:06, 4F

11/25 18:31, , 5F
應該沒有影響
11/25 18:31, 5F
文章代碼(AID): #1CxV-O8V (C_Sharp)
文章代碼(AID): #1CxV-O8V (C_Sharp)