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",
"colorowderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items.Attributes.Add("style",
"background-colorowderblue; ");
}
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-colorowderblue;">
<option selected="selected" value="" style="background-colorowderblue;
"></option>
<option value="123 Main Street" style="background-colorowderblue; ">123
Main Street</option>
<option value="456 Boulevard" style="background-colorowderblue; ">456
Boulevard</option>
<option value="789 Avenue" style="background-colorowderblue; ">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",
"colorowderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items.Attributes.Add("style",
"background-colorowderblue; ");
}
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-colorowderblue;">
<option selected="selected" value="" style="background-colorowderblue;
"></option>
<option value="123 Main Street" style="background-colorowderblue; ">123
Main Street</option>
<option value="456 Boulevard" style="background-colorowderblue; ">456
Boulevard</option>
<option value="789 Avenue" style="background-colorowderblue; ">789
Avenue</option>
</select>
</td>