DropDownList BackgroundColor not set

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:powderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items.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; ">123
Main Street</option>
<option value="456 Boulevard" style="background-color:powderblue; ">456
Boulevard</option>
<option value="789 Avenue" style="background-color:powderblue; ">789
Avenue</option>
</select>
</td>
 
J

Juan T. Llibre

Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

....or some such variation.
 
J

Juan T. Llibre

I should have added that you can set both the background
and foreground colors in the same style properties, but you know that, right ?

Attributes.Add("style", "background: red; color: white;")

....would give you white letters on a red background.




Juan T. Llibre said:
Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

...or some such variation.






Cliff Cotterill said:
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:powderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items.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; ">123 Main Street</option>
<option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option>
<option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option>
</select>
</td>

 
C

Cliff Cotterill

I tried it and the background-color still shows as a dark gray.
Here's the HTML it produced:
<select name="DropDownListWorkLocation" id="DropDownListWorkLocation"
tabindex="9" style="font-weight:bold;width:90%;background:powderblue">



Juan T. Llibre said:
Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

...or some such variation.






Cliff Cotterill said:
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:powderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items.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; ">123
Main Street</option>
<option value="456 Boulevard" style="background-color:powderblue; ">456
Boulevard</option>
<option value="789 Avenue" style="background-color:powderblue; ">789
Avenue</option>
</select>
</td>

 
C

Cliff Cotterill

That works with red and white, maybe there is a problem with
System.Drawing.Color.PowderBlue not being recognized ?


Juan T. Llibre said:
I should have added that you can set both the background
and foreground colors in the same style properties, but you know that,
right ?

Attributes.Add("style", "background: red; color: white;")

...would give you white letters on a red background.




Juan T. Llibre said:
Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style",
"background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

...or some such variation.






Cliff Cotterill said:
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:powderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items.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;
">123 Main Street</option>
<option value="456 Boulevard" style="background-color:powderblue; ">456
Boulevard</option>
<option value="789 Avenue" style="background-color:powderblue; ">789
Avenue</option>
</select>
</td>


 
J

Juan T. Llibre

re:
!> That works with red and white, maybe there is a problem with
!> System.Drawing.Color.PowderBlue not being recognized ?

According to :

http://msdn2.microsoft.com/en-us/library/system.drawing.color_properties(VS.80).aspx

....it should be recognized.

PowderBlue is a system-defined color.

Instead of passing the whole qualified name, try passing just the color name itself:

i.e., instead of :
System.Drawing.Color.PowderBlue;

use :
PowderBlue;




Cliff Cotterill said:
That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?


Juan T. Llibre said:
I should have added that you can set both the background
and foreground colors in the same style properties, but you know that, right ?

Attributes.Add("style", "background: red; color: white;")

...would give you white letters on a red background.




Juan T. Llibre said:
Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

...or some such variation.






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


 
J

Juan T. Llibre

See PowderBlue rendered in my example at :

http://asp.net.do/test/dropdowncolor3.aspx

That example uses :

DDL1.Items(i).Attributes.Add("style", "background:powderBlue")





Juan T. Llibre said:
re:
!> That works with red and white, maybe there is a problem with
!> System.Drawing.Color.PowderBlue not being recognized ?

According to :

http://msdn2.microsoft.com/en-us/library/system.drawing.color_properties(VS.80).aspx

...it should be recognized.

PowderBlue is a system-defined color.

Instead of passing the whole qualified name, try passing just the color name itself:

i.e., instead of :
System.Drawing.Color.PowderBlue;

use :
PowderBlue;




Cliff Cotterill said:
That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?


Juan T. Llibre said:
I should have added that you can set both the background
and foreground colors in the same style properties, but you know that, right ?

Attributes.Add("style", "background: red; color: white;")

...would give you white letters on a red background.




Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

...or some such variation.






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


 
C

Cliff Cotterill

I tried that and background:blue changes the color to blue, but
background:powderBlue displays as dark gray:
DropDownListWorkLocation.Items.Attributes.Add("style",
"background:powderBlue; ");
It looks like it recognizes basic colors like red, blue, white, black ....
but not all of those defined in System.Drawing.Color


Juan T. Llibre said:
See PowderBlue rendered in my example at :

http://asp.net.do/test/dropdowncolor3.aspx

That example uses :

DDL1.Items(i).Attributes.Add("style", "background:powderBlue")





Juan T. Llibre said:
re:
!> That works with red and white, maybe there is a problem with
!> System.Drawing.Color.PowderBlue not being recognized ?

According to :

http://msdn2.microsoft.com/en-us/library/system.drawing.color_properties(VS.80).aspx

...it should be recognized.

PowderBlue is a system-defined color.

Instead of passing the whole qualified name, try passing just the color
name itself:

i.e., instead of :
System.Drawing.Color.PowderBlue;

use :
PowderBlue;




Cliff Cotterill said:
That works with red and white, maybe there is a problem with
System.Drawing.Color.PowderBlue not being recognized ?


I should have added that you can set both the background
and foreground colors in the same style properties, but you know that,
right ?

Attributes.Add("style", "background: red; color: white;")

...would give you white letters on a red background.




Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style",
"background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

...or some such variation.






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


 
J

Juan T. Llibre

Cliff,

See PowderBlue rendered in my example at :

http://asp.net.do/test/dropdowncolor3.aspx

How does that appear when you view it ?
Can you see PowderBlue...or do you see dark gray ?





Cliff Cotterill said:
I tried that and background:blue changes the color to blue, but background:powderBlue displays as dark gray:
DropDownListWorkLocation.Items.Attributes.Add("style", "background:powderBlue; ");
It looks like it recognizes basic colors like red, blue, white, black .... but not all of those defined in
System.Drawing.Color


Juan T. Llibre said:
See PowderBlue rendered in my example at :

http://asp.net.do/test/dropdowncolor3.aspx

That example uses :

DDL1.Items(i).Attributes.Add("style", "background:powderBlue")





Juan T. Llibre said:
re:
!> That works with red and white, maybe there is a problem with
!> System.Drawing.Color.PowderBlue not being recognized ?

According to :

http://msdn2.microsoft.com/en-us/library/system.drawing.color_properties(VS.80).aspx

...it should be recognized.

PowderBlue is a system-defined color.

Instead of passing the whole qualified name, try passing just the color name itself:

i.e., instead of :
System.Drawing.Color.PowderBlue;

use :
PowderBlue;




That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?


I should have added that you can set both the background
and foreground colors in the same style properties, but you know that, right ?

Attributes.Add("style", "background: red; color: white;")

...would give you white letters on a red background.




Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

...or some such variation.






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


 
C

Cliff Cotterill

I can see a greenish-blue / aqua / turquoise color. Not dark gray, and not
the same as PowderBlue displays (here).
Your scroll bar components look more like PowderBlue.


Juan T. Llibre said:
Cliff,

See PowderBlue rendered in my example at :

http://asp.net.do/test/dropdowncolor3.aspx

How does that appear when you view it ?
Can you see PowderBlue...or do you see dark gray ?





Cliff Cotterill said:
I tried that and background:blue changes the color to blue, but
background:powderBlue displays as dark gray:
DropDownListWorkLocation.Items.Attributes.Add("style",
"background:powderBlue; ");
It looks like it recognizes basic colors like red, blue, white, black
.... but not all of those defined in System.Drawing.Color


Juan T. Llibre said:
See PowderBlue rendered in my example at :

http://asp.net.do/test/dropdowncolor3.aspx

That example uses :

DDL1.Items(i).Attributes.Add("style", "background:powderBlue")





re:
!> That works with red and white, maybe there is a problem with
!> System.Drawing.Color.PowderBlue not being recognized ?

According to :

http://msdn2.microsoft.com/en-us/library/system.drawing.color_properties(VS.80).aspx

...it should be recognized.

PowderBlue is a system-defined color.

Instead of passing the whole qualified name, try passing just the color
name itself:

i.e., instead of :
System.Drawing.Color.PowderBlue;

use :
PowderBlue;




That works with red and white, maybe there is a problem with
System.Drawing.Color.PowderBlue not being recognized ?


I should have added that you can set both the background
and foreground colors in the same style properties, but you know
that, right ?

Attributes.Add("style", "background: red; color: white;")

...would give you white letters on a red background.




Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style",
"background:powderblue");

If you want to apply different colors to different rows, adapt this
:

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style",
"background:yellow")
End If

...or some such variation.






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


 
J

Juan T. Llibre

Are you sure you don't suffer from daltonism ?

<only kidding...>





Cliff Cotterill said:
I can see a greenish-blue / aqua / turquoise color. Not dark gray, and not the same as PowderBlue displays (here).
Your scroll bar components look more like PowderBlue.


Juan T. Llibre said:
Cliff,

See PowderBlue rendered in my example at :

http://asp.net.do/test/dropdowncolor3.aspx

How does that appear when you view it ?
Can you see PowderBlue...or do you see dark gray ?





Cliff Cotterill said:
I tried that and background:blue changes the color to blue, but background:powderBlue displays as dark gray:
DropDownListWorkLocation.Items.Attributes.Add("style", "background:powderBlue; ");
It looks like it recognizes basic colors like red, blue, white, black .... but not all of those defined in
System.Drawing.Color


See PowderBlue rendered in my example at :

http://asp.net.do/test/dropdowncolor3.aspx

That example uses :

DDL1.Items(i).Attributes.Add("style", "background:powderBlue")





re:
!> That works with red and white, maybe there is a problem with
!> System.Drawing.Color.PowderBlue not being recognized ?

According to :

http://msdn2.microsoft.com/en-us/library/system.drawing.color_properties(VS.80).aspx

...it should be recognized.

PowderBlue is a system-defined color.

Instead of passing the whole qualified name, try passing just the color name itself:

i.e., instead of :
System.Drawing.Color.PowderBlue;

use :
PowderBlue;




That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized
?


I should have added that you can set both the background
and foreground colors in the same style properties, but you know that, right ?

Attributes.Add("style", "background: red; color: white;")

...would give you white letters on a red background.




Hi, Cliff.

Use :

DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");

If you want to apply different colors to different rows, adapt this :

If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If

...or some such variation.






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


 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top