473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DropDownList BackgroundColor not set

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[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; ">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>
Nov 15 '07 #1
10 2221
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.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
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[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; ">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>


Nov 15 '07 #2
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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl...
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.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
>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[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; ">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>



Nov 15 '07 #3
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" <no***********@nowhere.comwrote in message
news:OD**************@TK2MSFTNGP06.phx.gbl...
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.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>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[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; ">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>



Nov 15 '07 #4
That works with red and white, maybe there is a problem with
System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e%****************@TK2MSFTNGP06.phx.gbl...
>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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OD**************@TK2MSFTNGP06.phx.gbl...
>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.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>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.BackColo r =
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;
">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>




Nov 15 '07 #5
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/lib...es(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;

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl...
That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl...
>>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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl...
>>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.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
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.BackCol or = System.Drawing.Color.PowderBlue;
DropDownListWorkLocation.Attributes.CssStyle.Ad d("background-repeat", "repeat-y");
DropDownListWorkLocation.Attributes.CssStyle.Ad d("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; ">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>




Nov 15 '07 #6
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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2***************@TK2MSFTNGP04.phx.gbl...
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/lib...es(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;

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl...
>That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl...
>>>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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl...
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.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
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.BackColo r = System.Drawing.Color.PowderBlue;
DropDownListWorkLocation.Attributes.CssStyle.A dd("background-repeat", "repeat-y");
DropDownListWorkLocation.Attributes.CssStyle.A dd("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; ">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>
>
>




Nov 15 '07 #7
I tried that and background:blue changes the color to blue, but
background:PowderBlue displays as dark gray:
DropDownListWorkLocation.Items[i].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" <no***********@nowhere.comwrote in message
news:ei**************@TK2MSFTNGP06.phx.gbl...
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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
>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/lib...es(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;

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message
news:uq**************@TK2MSFTNGP05.phx.gbl...
>>That works with red and white, maybe there is a problem with
System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e%****************@TK2MSFTNGP06.phx.gbl.. .
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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OD**************@TK2MSFTNGP06.phx.gbl...
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.
>
>
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>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.BackCol or =
>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;
>">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>
>>
>>
>
>




Nov 15 '07 #8
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 ?


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
>I tried that and background:blue changes the color to blue, but background:PowderBlue displays as dark gray:
DropDownListWorkLocation.Items[i].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" <no***********@nowhere.comwrote in message news:ei**************@TK2MSFTNGP06.phx.gbl...
>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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2***************@TK2MSFTNGP04.phx.gbl...
>>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/lib...es(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;

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl...
That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl...
>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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl...
>Hi, Cliff.
>>
>Use :
>>
>DropDownListWorkLocation.Attributes.Add("styl e", "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("styl e", "background:red")
>Else
>DropDownListWorkLocation.Attributes.Add("styl e", "background:yellow")
>End If
>>
>...or some such variation.
>>
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en español : http://asp.net.do/foros/
>======================================
>"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
>>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.BackCo lor = 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; ">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>
>>>
>>>
>>
>>
>
>




Nov 15 '07 #9
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" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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 ?


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>I tried that and background:blue changes the color to blue, but
background:PowderBlue displays as dark gray:
DropDownListWorkLocation.Items[i].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" <no***********@nowhere.comwrote in message
news:ei**************@TK2MSFTNGP06.phx.gbl...
>>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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
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/lib...es(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;

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message
news:uq**************@TK2MSFTNGP05.phx.gbl...
That works with red and white, maybe there is a problem with
System.Drawing.Color.PowderBlue not being recognized ?
>
>
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e%****************@TK2MSFTNGP06.phx.gbl.. .
>>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, asp.net MVP
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en español : http://asp.net.do/foros/
>======================================
>"Juan T. Llibre" <no***********@nowhere.comwrote in message
>news:OD**************@TK2MSFTNGP06.phx.gbl. ..
>>Hi, Cliff.
>>>
>>Use :
>>>
>>DropDownListWorkLocation.Attributes.Add("sty le",
>>"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("sty le", "background:red")
>>Else
>>DropDownListWorkLocation.Attributes.Add("sty le",
>>"background:yellow")
>>End If
>>>
>>...or some such variation.
>>>
>>>
>>>
>>>
>>>
>>Juan T. Llibre, asp.net MVP
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en español : http://asp.net.do/foros/
>>======================================
>>"Cliff Cotterill" <cl*************@intusurg.comwrote in message
>>news:%2****************@TK2MSFTNGP02.phx.gbl ...
>>>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.BackC olor =
>>>System.Drawing.Color.PowderBlue;
>>>DropDownListWorkLocation.Attributes.CssStyl e.Add("background-repeat",
>>>"repeat-y");
>>>DropDownListWorkLocation.Attributes.CssStyl e.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;
>>>">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>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Nov 15 '07 #10
Are you sure you don't suffer from daltonism ?

<only kidding...>


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
>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" <no***********@nowhere.comwrote in message news:%2****************@TK2MSFTNGP04.phx.gbl...
>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 ?


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
>>>I tried that and background:blue changes the color to blue, but background:PowderBlue displays as dark gray:
DropDownListWorkLocation.Items[i].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" <no***********@nowhere.comwrote in message news:ei**************@TK2MSFTNGP06.phx.gbl...
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, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2***************@TK2MSFTNGP04.phx.gbl...
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/lib...es(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;
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl...
>That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized
>?
>>
>>
>"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl...
>>>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, asp.net MVP
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en español : http://asp.net.do/foros/
>>======================================
>>"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl...
>>>Hi, Cliff.
>>>>
>>>Use :
>>>>
>>>DropDownListWorkLocation.Attributes.Add("st yle", "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("st yle", "background:red")
>>>Else
>>>DropDownListWorkLocation.Attributes.Add("st yle", "background:yellow")
>>>End If
>>>>
>>>...or some such variation.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>Juan T. Llibre, asp.net MVP
>>>asp.net faq : http://asp.net.do/faq/
>>>foros de asp.net, en español : http://asp.net.do/foros/
>>>======================================
>>>"Cliff Cotterill" <cl*************@intusurg.comwrote in message
>>>news:%2****************@TK2MSFTNGP02.phx.gb l...
>>>>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.Back Color = System.Drawing.Color.PowderBlue;
>>>>DropDownListWorkLocation.Attributes.CssSty le.Add("background-repeat", "repeat-y");
>>>>DropDownListWorkLocation.Attributes.CssSty le.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; ">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>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>




Nov 16 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philip | last post by:
Hey, Is it possible to get the default value of an element's style.backgroundColor property that's set in a css class? Example, since I'm very tired and can't word that any better ;) ...
12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
1
by: RobG | last post by:
When I set the background colour of an element using tdRef.style.backgroundColor and then read it back, Firefox always gives rgb(r, g, b) regardless of whether I've used rgb(...) or #rrggbb to set...
13
by: cosmic foo | last post by:
if i change the backgroundColor of a tag to 'red', it works in both ie and mozilla. if i change the backgroundColor of a tag to 'redd', i get 'invalid property value' in ie, and no error in...
3
by: Gandalf | last post by:
I wish to apply different styles to items in a DropDownList. However, any styles applied in the codebehind (using the ListItem.Addtributes property) do not get rendered. This is an old question but...
2
by: jason | last post by:
Pardon my ignorance on this. The below code works, except, when I edit a record and update the two drop downs take the first entry in the dropdownlist if not selected. I'd also like the dropdown to...
6
by: fallen angel | last post by:
halu there!! i'm a 1month experienced java scripter but got a good hang of it already. hehehe.. i developed a "color selection" tool, similar to the one in flash when you choose a color for a...
4
by: André | last post by:
Hi, i created a table with cells. One cell has background-color (LightSlateGray) and contains a label without text but also with a backgroundcolor (red). The width of the label is set by a value...
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.