asp.net里的关于dropdownlist控件的问题!
我做了一个新闻发布系统。希望在新闻添加的时候,可以选择新闻标题的颜色。希望通过一个dropdownlist控件实现html里能够实现的这种效果:<selectname='...
我做了一个新闻发布系统。希望在新闻添加的时候,可以选择新闻标题的颜色。希望通过一个dropdownlist控件实现html里能够实现的这种效果:
<select name='TitleFontColor' id='TitleFontColor'>
<option value='' selected>颜色</option>
<option value=''>默认</option>
<option value='#000000' style='background-color:#000000'></option>
<option value='#FFFFFF' style='background-color:#FFFFFF'></option>
<option value='#008000' style='background-color:#008000'></option>
<option value='#800000' style='background-color:#800000'></option>
<option value='#808000' style='background-color:#808000'></option>
<option value='#000080' style='background-color:#000080'></option>
<option value='#800080' style='background-color:#800080'></option>
<option value='#808080' style='background-color:#808080'></option>
<option value='#FFFF00' style='background-color:#FFFF00'></option>
<option value='#00FF00' style='background-color:#00FF00'></option>
<option value='#00FFFF' style='background-color:#00FFFF'></option>
<option value='#FF00FF' style='background-color:#FF00FF'></option>
<option value='#FF0000' style='background-color:#FF0000'></option>
<option value='#0000FF' style='background-color:#0000FF'></option>
<option value='#008080' style='background-color:#008080'></option>
</select>
也就是说像系统颜色选择一样从下拉菜单中选择自己想要的颜色。请各位大侠帮忙给个具体例子!
这个很好啊,不过我做的这个是用C#的!
如果用C#应该怎么做啊? 展开
<select name='TitleFontColor' id='TitleFontColor'>
<option value='' selected>颜色</option>
<option value=''>默认</option>
<option value='#000000' style='background-color:#000000'></option>
<option value='#FFFFFF' style='background-color:#FFFFFF'></option>
<option value='#008000' style='background-color:#008000'></option>
<option value='#800000' style='background-color:#800000'></option>
<option value='#808000' style='background-color:#808000'></option>
<option value='#000080' style='background-color:#000080'></option>
<option value='#800080' style='background-color:#800080'></option>
<option value='#808080' style='background-color:#808080'></option>
<option value='#FFFF00' style='background-color:#FFFF00'></option>
<option value='#00FF00' style='background-color:#00FF00'></option>
<option value='#00FFFF' style='background-color:#00FFFF'></option>
<option value='#FF00FF' style='background-color:#FF00FF'></option>
<option value='#FF0000' style='background-color:#FF0000'></option>
<option value='#0000FF' style='background-color:#0000FF'></option>
<option value='#008080' style='background-color:#008080'></option>
</select>
也就是说像系统颜色选择一样从下拉菜单中选择自己想要的颜色。请各位大侠帮忙给个具体例子!
这个很好啊,不过我做的这个是用C#的!
如果用C#应该怎么做啊? 展开
2个回答
展开全部
我稍加修改了一下,不知是否合你的意。?代码如下:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub TitleFontColor_change(ByVal sender As Object, ByVal e As System.EventArgs)
Title_text.Style("background-color") = DropDownList1.SelectedValue
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div id="Title_text" runat="server">这里是要变色的标题</div><p/>
<div>颜色:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="TitleFontColor_change">
<asp:ListItem value='' selected="True">默认</asp:ListItem>
<asp:ListItem value="#000000" style="background-color:#000000"></asp:ListItem>
<asp:ListItem value='#000000' style='background-color:#000000'></asp:ListItem>
<asp:ListItem value='#FFFFFF' style='background-color:#FFFFFF'></asp:ListItem>
<asp:ListItem value='#008000' style='background-color:#008000'></asp:ListItem>
<asp:ListItem value='#800000' style='background-color:#800000'></asp:ListItem>
<asp:ListItem value='#808000' style='background-color:#808000'></asp:ListItem>
<asp:ListItem value='#000080' style='background-color:#000080'></asp:ListItem>
<asp:ListItem value='#800080' style='background-color:#800080'></asp:ListItem>
<asp:ListItem value='#808080' style='background-color:#808080'></asp:ListItem>
<asp:ListItem value='#FFFF00' style='background-color:#FFFF00'></asp:ListItem>
<asp:ListItem value='#00FF00' style='background-color:#00FF00'></asp:ListItem>
<asp:ListItem value='#00FFFF' style='background-color:#00FFFF'></asp:ListItem>
<asp:ListItem value='#FF00FF' style='background-color:#FF00FF'></asp:ListItem>
<asp:ListItem value='#FF0000' style='background-color:#FF0000'></asp:ListItem>
<asp:ListItem value='#0000FF' style='background-color:#0000FF'></asp:ListItem>
<asp:ListItem value='#008080' style='background-color:#008080'></asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub TitleFontColor_change(ByVal sender As Object, ByVal e As System.EventArgs)
Title_text.Style("background-color") = DropDownList1.SelectedValue
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div id="Title_text" runat="server">这里是要变色的标题</div><p/>
<div>颜色:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="TitleFontColor_change">
<asp:ListItem value='' selected="True">默认</asp:ListItem>
<asp:ListItem value="#000000" style="background-color:#000000"></asp:ListItem>
<asp:ListItem value='#000000' style='background-color:#000000'></asp:ListItem>
<asp:ListItem value='#FFFFFF' style='background-color:#FFFFFF'></asp:ListItem>
<asp:ListItem value='#008000' style='background-color:#008000'></asp:ListItem>
<asp:ListItem value='#800000' style='background-color:#800000'></asp:ListItem>
<asp:ListItem value='#808000' style='background-color:#808000'></asp:ListItem>
<asp:ListItem value='#000080' style='background-color:#000080'></asp:ListItem>
<asp:ListItem value='#800080' style='background-color:#800080'></asp:ListItem>
<asp:ListItem value='#808080' style='background-color:#808080'></asp:ListItem>
<asp:ListItem value='#FFFF00' style='background-color:#FFFF00'></asp:ListItem>
<asp:ListItem value='#00FF00' style='background-color:#00FF00'></asp:ListItem>
<asp:ListItem value='#00FFFF' style='background-color:#00FFFF'></asp:ListItem>
<asp:ListItem value='#FF00FF' style='background-color:#FF00FF'></asp:ListItem>
<asp:ListItem value='#FF0000' style='background-color:#FF0000'></asp:ListItem>
<asp:ListItem value='#0000FF' style='background-color:#0000FF'></asp:ListItem>
<asp:ListItem value='#008080' style='background-color:#008080'></asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询