本文介绍了DropDownList BackgroundColor未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我已经尝试了多种设置DropDownList背景颜色的方法, 但似乎没有工作。 如何设置颜色? 我已经尝试设置DrowDownList组件的BackGroundColor,并且 也为每个列表项设置它。 生成的.html代码看起来正确。为什么不显示颜色? 代码 DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.ControlStyle.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.Attributes.CssStyle.Add(" background-repeat", " repeat-y"); DropDownListWorkLocation.Attributes.CssStyle.Add(" background-color", " powderblue"); DropDownListWorkLocation.Items [0] .Attributes.Add(" style", " color:powderblue"); for(int i = 0; i< DropDownListWorkLocation.Items.Count; i ++) { DropDownListWorkLocation.Items [i] .Attributes.Add(" style",&br / > " background-color:powderblue;"); } 结果HTML < td style =" height:20px;" NOWRAP = QUOT; NOWRAP" width =" 19%"> < select name =" DropDownListWorkLocation" id =" DropDownListWorkLocation" tabindex =" 9" style =" font-weight:bold; width:90%; background-repeat:repeat-y ; background-color:powderblue;"> < option selected =" selected"值= QUOT;" style =" background-color:powderblue; ">< / option> < option value =" 123 Main Street"风格= QUOT;背景色:灰蓝; "> 123 Main Street< / option> < option value =" 456 Boulevard"风格= QUOT;背景色:灰蓝; "> 456 Boulevard< / option> < option value =" 789 Avenue"风格= QUOT;背景色:灰蓝; "> 789 Avenue< / option> < / select> < / td>I''ve tried multiple ways of setting the background-color of a DropDownList,but none seem to work.How can the color be set?I''ve tried setting the BackGroundColor of the DrowDownList component, andalso setting it for each of the List Items.The resulting .html code looks correct. Why doesn''t the color display?CodeDropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue;DropDownListWorkLocation.ControlStyle.BackColor =System.Drawing.Color.PowderBlue;DropDownListWorkLocation.Attributes.CssStyle.Add(" background-repeat","repeat-y");DropDownListWorkLocation.Attributes.CssStyle.Add(" background-color","powderblue");DropDownListWorkLocation.Items[0].Attributes.Add("style","color:powderblue");for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++){DropDownListWorkLocation.Items[i].Attributes.Add("style","background-color:powderblue; ");}Resulting HTML<td style="height: 20px;" nowrap="noWrap" width="19%"><select name="DropDownListWorkLocation" id="DropDownListWorkLocation"tabindex="9"style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"><option selected="selected" value="" style="background-color:powderblue;"></option><option value="123 Main Street" style="background-color:powderblue; ">123Main Street</option><option value="456 Boulevard" style="background-color:powderblue; ">456Boulevard</option><option value="789 Avenue" style="background-color:powderblue; ">789Avenue</option></select></td>推荐答案 这篇关于DropDownList BackgroundColor未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 05:46