C
Cliff Cotterill
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, and
also setting it for each of the List Items.
The resulting .html code looks correct. Why doesn't the color display?
Code
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
owderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items.Attributes.Add("style",
"background-color
owderblue; ");
}
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
owderblue;">
<option selected="selected" value="" style="background-color
owderblue;
"></option>
<option value="123 Main Street" style="background-color
owderblue; ">123
Main Street</option>
<option value="456 Boulevard" style="background-color
owderblue; ">456
Boulevard</option>
<option value="789 Avenue" style="background-color
owderblue; ">789
Avenue</option>
</select>
</td>
but none seem to work.
How can the color be set?
I've tried setting the BackGroundColor of the DrowDownList component, and
also setting it for each of the List Items.
The resulting .html code looks correct. Why doesn't the color display?
Code
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

for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items.Attributes.Add("style",
"background-color

}
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

<option selected="selected" value="" style="background-color

"></option>
<option value="123 Main Street" style="background-color

Main Street</option>
<option value="456 Boulevard" style="background-color

Boulevard</option>
<option value="789 Avenue" style="background-color

Avenue</option>
</select>
</td>