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> 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>
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>
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>
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>
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>
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> > >
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> >> >> > >
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> >>> >>> >> >> > >
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> >>>> >>>> >>> >>> >> >> > >
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> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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 ;)
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
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,...
|
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...
| |