如何把 DropDownList 某一个 Item 的 Text 改成粗体 ?
生活随笔
收集整理的這篇文章主要介紹了
如何把 DropDownList 某一个 Item 的 Text 改成粗体 ?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這是昨天 CSDN 里面的一個帖子?
http://community.csdn.net/Expert/TopicView3.asp?id=5637788
今天發現竟然成為頭條了。
本以為,可以像設置字體顏色一樣設置字形,結果大出意料,只有 FF 才可以呈現出預期的效果。
測試代碼:
<%@?Page?Language="C#"?%><!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script?runat="server">
????protected?void?Page_Load(object?sender,?EventArgs?e)
????{
????????ListItem?item?=?null;
????????item?=?new?ListItem("Red--Setting?by?code-programming",?"red");????????
????????item.Attributes["style"]?=?"color:?"?+?item.Value;
????????DropDownList1.Items.Add(item);
????????item?=?new?ListItem("Bold?Font?--Setting?by?code-programming",?"bold");
????????item.Attributes["style"]?=?"font-weight:"?+?item.Value;
????????DropDownList1.Items.Add(item);
????????
????????item?=?new?ListItem("none");
????????DropDownList1.Items.Add(item);
????}
</script>
<html?xmlns="http://www.w3.org/1999/xhtml"?>
<head?runat="server">
????<title>ListItemStyle_FontWeight_Test</title>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
????????<asp:DropDownList?ID="DropDownList1"?runat="server">????????
????????<asp:ListItem?style="color:green">Green--Setting?by?declarative-style</asp:ListItem>
????????<asp:ListItem?style="font-weight:bold">Blod?Font?----Setting?by?declarative-style</asp:ListItem>
????????</asp:DropDownList></div>
????</form>
</body>
</html>
效果:
只有 FF 最感冒了, 但是當選中某一項后,顏色恢復到整個 select 的設置。
轉載于:https://www.cnblogs.com/Jinglecat/archive/2007/07/06/809157.html
總結
以上是生活随笔為你收集整理的如何把 DropDownList 某一个 Item 的 Text 改成粗体 ?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 页面间参数值传递含“%”的处理方法
- 下一篇: mysql统计各部门人数_2021各省份