我想让"Red"的背景色为红色
Blue的背景色为蓝色,依此类推.
就向聊天室中的有个下拉菜单可以为你要发的消息选择字体的颜色的那个控件.
该如何实现
请高手多多指教
---------------------------------------------------------------
(Eddie005):
dropdownlist难,但是可以用System.Web.UI.HtmlControls.HtmlSelect Select1;
<SELECT id="Select1" style="POSITION: absolute;"name="Select1" runat="server">
<OPTION selected></OPTION>
</SELECT>
DataTable ttt = new DataTable();
ttt.Columns.Add("aaa");
ttt.Columns.Add("bbb");
ttt.Rows.Add(new object[]{"1","WWWWWWW"});
ttt.Rows.Add(new object[]{"2","QQQQQQQ"});
this.Select1.DataSource = ttt;
this.Select1.DataValueField = "aaa";
this.Select1.DataTextField = "bbb";
this.Select1.DataBind();
this.Select1.Items[0].Attributes.Add("style","BACKGROUND-COLOR:yellow");
this.Select1.Items[1].Attributes.Add("style","BACKGROUND-COLOR:lightblue");
---------------------------------------------------------------
(nickycheng)脚本控制:
<SCRIPT language="JScript">
function chgColor(obj){
obj.options[0].style.backgroundColor = "red";
obj.options[1].style.backgroundColor = "blue";
}
</script>
<SCRIPT language="JScript" event="onload" for="window">
chgColor(document.all("DropDownList"))
</SCRIPT>
Blue的背景色为蓝色,依此类推.
就向聊天室中的有个下拉菜单可以为你要发的消息选择字体的颜色的那个控件.
该如何实现
请高手多多指教
---------------------------------------------------------------
(Eddie005):
dropdownlist难,但是可以用System.Web.UI.HtmlControls.HtmlSelect Select1;
<SELECT id="Select1" style="POSITION: absolute;"name="Select1" runat="server">
<OPTION selected></OPTION>
</SELECT>
DataTable ttt = new DataTable();
ttt.Columns.Add("aaa");
ttt.Columns.Add("bbb");
ttt.Rows.Add(new object[]{"1","WWWWWWW"});
ttt.Rows.Add(new object[]{"2","QQQQQQQ"});
this.Select1.DataSource = ttt;
this.Select1.DataValueField = "aaa";
this.Select1.DataTextField = "bbb";
this.Select1.DataBind();
this.Select1.Items[0].Attributes.Add("style","BACKGROUND-COLOR:yellow");
this.Select1.Items[1].Attributes.Add("style","BACKGROUND-COLOR:lightblue");
---------------------------------------------------------------
(nickycheng)脚本控制:
<SCRIPT language="JScript">
function chgColor(obj){
obj.options[0].style.backgroundColor = "red";
obj.options[1].style.backgroundColor = "blue";
}
</script>
<SCRIPT language="JScript" event="onload" for="window">
chgColor(document.all("DropDownList"))
</SCRIPT>