HighTechTalks DotNet Forums  

Colors

Dotnet FAQs microsoft.public.dotnet.faqs


Discuss Colors in the Dotnet FAQs forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Paul Smith
 
Posts: n/a

Default Colors - 08-19-2005 , 06:28 PM






I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

Help!



Reply With Quote
  #2  
Old   
Scott M.
 
Posts: n/a

Default Re: Colors - 08-19-2005 , 06:41 PM






color.fromArgb(rr, gg, bb)

where rr, gg, bb are the red, green and blue values that should be mixed to
produce the color you desire.

Microsoft can supply the color class with every color under the sun.
They've provided a good base of colors, but for custom colors, you'll need
to supply the ingredients yourself.



"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote

Quote:
I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

Help!





Reply With Quote
  #3  
Old   
Paul Smith
 
Posts: n/a

Default Re: Colors - 08-20-2005 , 01:29 AM



When I manually look at the properties of a web control and check it's
backcolor, I see that the color 'Gainsboro' has been selected from the web
color palette. Is it true that in code you cannot change a control's
backcolor to another color from the web palette?

I am a novice programmer, but this seems very strange that you need to
reference code color changes using RGB references, when manually you can
using defined named colors. If this is the case where do you get the RGB
values for each names colour?

PWS



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote

Quote:
color.fromArgb(rr, gg, bb)

where rr, gg, bb are the red, green and blue values that should be mixed
to produce the color you desire.

Microsoft can supply the color class with every color under the sun.
They've provided a good base of colors, but for custom colors, you'll need
to supply the ingredients yourself.



"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:43066b16$0$97123$ed2619ec (AT) ptn-nntp-reader03 (DOT) plus.net...
I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

Help!







Reply With Quote
  #4  
Old   
Scott M.
 
Posts: n/a

Default Re: Colors - 08-20-2005 , 12:47 PM



While the Properties window does show Gainsboro in the list, remember that
the values you select in the Properties window for web forms controls must
be able to be expressed (or better yet, rendered) to the client (browser) as
something the browser will understand. This is why a Web Forms control
might start out as: <ASP:Button>, but it winds up in the client as <INPUT
TYPE="Submit">. The same is true with property values. The only way to
specify a background color for an HTML control is via Cascading Style Sheets
and the STYLE attribute of the <INPUT> tag.

Now, here's the important part: in CSS, Gainsboro is a valid value for the
"background-color:" style sheet property, BUT there are 2 additional things
to consider...

1. Gainsboro is just a name that your video card must be able to present to
you. Not everyone has the same video card that you have and it is quite
possible that many people's systems will have no idea what Gainsboro is.

2. Even though on your system Gainsboro is a known color and even though
the Cascading Style Sheet language accepts Gainsboro as a value for the
"background-color:" style property, when you are working in .NET code, you
are not working in the Cascading Style Sheet language. You are working in a
different language that will be processed by a web server and the .NET
Framework, not a client browser and a video card. Because of this, you must
use the Color class. Microsoft certainly can't create constant values in
the color class for every color there is, so they created constants exposed
as properties for quite a few common colors. For all other colors, they
gave us the "FromARGB" method to "mix" up a color as we see fit.

To get the RGB of virtually any named color, a simple Google search on:
"gainsboro rgb" returns as the very first result, that 220, 220, 220 is the
RGB for Gainsboro.


-Scott


"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote

Quote:
When I manually look at the properties of a web control and check it's
backcolor, I see that the color 'Gainsboro' has been selected from the web
color palette. Is it true that in code you cannot change a control's
backcolor to another color from the web palette?

I am a novice programmer, but this seems very strange that you need to
reference code color changes using RGB references, when manually you can
using defined named colors. If this is the case where do you get the RGB
values for each names colour?

PWS



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote in message
news:e9J6ZeRpFHA.764 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
color.fromArgb(rr, gg, bb)

where rr, gg, bb are the red, green and blue values that should be mixed
to produce the color you desire.

Microsoft can supply the color class with every color under the sun.
They've provided a good base of colors, but for custom colors, you'll
need to supply the ingredients yourself.



"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:43066b16$0$97123$ed2619ec (AT) ptn-nntp-reader03 (DOT) plus.net...
I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

Help!









Reply With Quote
  #5  
Old   
Paul Smith
 
Posts: n/a

Default Re: Colors - 08-20-2005 , 03:17 PM



Scott,

Thank you for taking the time to give such a detailed explanation, I do
appreciate, and now understand, the issue.

PWS



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote

Quote:
While the Properties window does show Gainsboro in the list, remember that
the values you select in the Properties window for web forms controls must
be able to be expressed (or better yet, rendered) to the client (browser)
as something the browser will understand. This is why a Web Forms control
might start out as: <ASP:Button>, but it winds up in the client as <INPUT
TYPE="Submit">. The same is true with property values. The only way to
specify a background color for an HTML control is via Cascading Style
Sheets and the STYLE attribute of the <INPUT> tag.

Now, here's the important part: in CSS, Gainsboro is a valid value for the
"background-color:" style sheet property, BUT there are 2 additional
things to consider...

1. Gainsboro is just a name that your video card must be able to present
to you. Not everyone has the same video card that you have and it is
quite possible that many people's systems will have no idea what Gainsboro
is.

2. Even though on your system Gainsboro is a known color and even though
the Cascading Style Sheet language accepts Gainsboro as a value for the
"background-color:" style property, when you are working in .NET code, you
are not working in the Cascading Style Sheet language. You are working in
a different language that will be processed by a web server and the .NET
Framework, not a client browser and a video card. Because of this, you
must use the Color class. Microsoft certainly can't create constant
values in the color class for every color there is, so they created
constants exposed as properties for quite a few common colors. For all
other colors, they gave us the "FromARGB" method to "mix" up a color as we
see fit.

To get the RGB of virtually any named color, a simple Google search on:
"gainsboro rgb" returns as the very first result, that 220, 220, 220 is
the RGB for Gainsboro.


-Scott


"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:4306cde4$0$17495$ed2e19e4 (AT) ptn-nntp-reader04 (DOT) plus.net...
When I manually look at the properties of a web control and check it's
backcolor, I see that the color 'Gainsboro' has been selected from the
web color palette. Is it true that in code you cannot change a control's
backcolor to another color from the web palette?

I am a novice programmer, but this seems very strange that you need to
reference code color changes using RGB references, when manually you can
using defined named colors. If this is the case where do you get the RGB
values for each names colour?

PWS



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote in message
news:e9J6ZeRpFHA.764 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
color.fromArgb(rr, gg, bb)

where rr, gg, bb are the red, green and blue values that should be mixed
to produce the color you desire.

Microsoft can supply the color class with every color under the sun.
They've provided a good base of colors, but for custom colors, you'll
need to supply the ingredients yourself.



"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:43066b16$0$97123$ed2619ec (AT) ptn-nntp-reader03 (DOT) plus.net...
I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

Help!











Reply With Quote
  #6  
Old   
Scott M.
 
Posts: n/a

Default Re: Colors - 08-20-2005 , 06:49 PM



No problem. Good luck.


"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote

Quote:
Scott,

Thank you for taking the time to give such a detailed explanation, I do
appreciate, and now understand, the issue.

PWS



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote in message
news:OHxTe9apFHA.3256 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
While the Properties window does show Gainsboro in the list, remember
that the values you select in the Properties window for web forms
controls must be able to be expressed (or better yet, rendered) to the
client (browser) as something the browser will understand. This is why a
Web Forms control might start out as: <ASP:Button>, but it winds up in
the client as <INPUT TYPE="Submit">. The same is true with property
values. The only way to specify a background color for an HTML control
is via Cascading Style Sheets and the STYLE attribute of the <INPUT> tag.

Now, here's the important part: in CSS, Gainsboro is a valid value for
the "background-color:" style sheet property, BUT there are 2 additional
things to consider...

1. Gainsboro is just a name that your video card must be able to present
to you. Not everyone has the same video card that you have and it is
quite possible that many people's systems will have no idea what
Gainsboro is.

2. Even though on your system Gainsboro is a known color and even though
the Cascading Style Sheet language accepts Gainsboro as a value for the
"background-color:" style property, when you are working in .NET code,
you are not working in the Cascading Style Sheet language. You are
working in a different language that will be processed by a web server
and the .NET Framework, not a client browser and a video card. Because
of this, you must use the Color class. Microsoft certainly can't create
constant values in the color class for every color there is, so they
created constants exposed as properties for quite a few common colors.
For all other colors, they gave us the "FromARGB" method to "mix" up a
color as we see fit.

To get the RGB of virtually any named color, a simple Google search on:
"gainsboro rgb" returns as the very first result, that 220, 220, 220 is
the RGB for Gainsboro.


-Scott


"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:4306cde4$0$17495$ed2e19e4 (AT) ptn-nntp-reader04 (DOT) plus.net...
When I manually look at the properties of a web control and check it's
backcolor, I see that the color 'Gainsboro' has been selected from the
web color palette. Is it true that in code you cannot change a
control's backcolor to another color from the web palette?

I am a novice programmer, but this seems very strange that you need to
reference code color changes using RGB references, when manually you can
using defined named colors. If this is the case where do you get the
RGB values for each names colour?

PWS



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote in message
news:e9J6ZeRpFHA.764 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
color.fromArgb(rr, gg, bb)

where rr, gg, bb are the red, green and blue values that should be
mixed to produce the color you desire.

Microsoft can supply the color class with every color under the sun.
They've provided a good base of colors, but for custom colors, you'll
need to supply the ingredients yourself.



"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:43066b16$0$97123$ed2619ec (AT) ptn-nntp-reader03 (DOT) plus.net...
I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

Help!













Reply With Quote
  #7  
Old   
Brendan Green
 
Posts: n/a

Default Re: Colors - 08-25-2005 , 09:23 PM



Excuse me, but I seriously don't think that the type of video card that you
have in your computer has anything to do with this.

The color "Gainsboro" would likely be defined in some web standard. As long
as the browsers *rendering engine* can interpret what Gainsboro should be,
it'll display fine.

The code that you are working on is executed server side. The resultant
output of this execution is valid HTML. The Color struct cotains
definitions for a set number of colors. If you want to use a colour that is
not provided, then you use the RGB representation instead.

"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote

Quote:
While the Properties window does show Gainsboro in the list, remember that
the values you select in the Properties window for web forms controls must
be able to be expressed (or better yet, rendered) to the client (browser)
as something the browser will understand. This is why a Web Forms control
might start out as: <ASP:Button>, but it winds up in the client as <INPUT
TYPE="Submit">. The same is true with property values. The only way to
specify a background color for an HTML control is via Cascading Style
Sheets and the STYLE attribute of the <INPUT> tag.

Now, here's the important part: in CSS, Gainsboro is a valid value for the
"background-color:" style sheet property, BUT there are 2 additional
things to consider...

1. Gainsboro is just a name that your video card must be able to present
to you. Not everyone has the same video card that you have and it is
quite possible that many people's systems will have no idea what Gainsboro
is.

2. Even though on your system Gainsboro is a known color and even though
the Cascading Style Sheet language accepts Gainsboro as a value for the
"background-color:" style property, when you are working in .NET code, you
are not working in the Cascading Style Sheet language. You are working in
a different language that will be processed by a web server and the .NET
Framework, not a client browser and a video card. Because of this, you
must use the Color class. Microsoft certainly can't create constant
values in the color class for every color there is, so they created
constants exposed as properties for quite a few common colors. For all
other colors, they gave us the "FromARGB" method to "mix" up a color as we
see fit.

To get the RGB of virtually any named color, a simple Google search on:
"gainsboro rgb" returns as the very first result, that 220, 220, 220 is
the RGB for Gainsboro.


-Scott


"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:4306cde4$0$17495$ed2e19e4 (AT) ptn-nntp-reader04 (DOT) plus.net...
When I manually look at the properties of a web control and check it's
backcolor, I see that the color 'Gainsboro' has been selected from the
web color palette. Is it true that in code you cannot change a control's
backcolor to another color from the web palette?

I am a novice programmer, but this seems very strange that you need to
reference code color changes using RGB references, when manually you can
using defined named colors. If this is the case where do you get the RGB
values for each names colour?

PWS



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote in message
news:e9J6ZeRpFHA.764 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
color.fromArgb(rr, gg, bb)

where rr, gg, bb are the red, green and blue values that should be mixed
to produce the color you desire.

Microsoft can supply the color class with every color under the sun.
They've provided a good base of colors, but for custom colors, you'll
need to supply the ingredients yourself.



"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:43066b16$0$97123$ed2619ec (AT) ptn-nntp-reader03 (DOT) plus.net...
I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

Help!











Reply With Quote
  #8  
Old   
Scott M.
 
Posts: n/a

Default Re: Colors - 08-26-2005 , 10:50 PM




"Brendan Green" <bgreen (AT) simtap (DOT) com.au> wrote

Quote:
Excuse me, but I seriously don't think that the type of video card that
you have in your computer has anything to do with this.
Well sorry, but it is a factor. If you have a video card that only knows
how to display 256 colors, then you aren't going to get Gainsboro.

Quote:
The color "Gainsboro" would likely be defined in some web standard. As
long as the browsers *rendering engine* can interpret what Gainsboro
should be, it'll display fine.
And, what web standard would that be? There are the colors defined as the
"Web Safe" colors and, yes, these colors do have names associated with them.
But the translation of those names into RGB values is in no way guaranteed
to happen in the same way from system to system.

Quote:
The code that you are working on is executed server side. The resultant
output of this execution is valid HTML.
Stop right there. If you look at the resulting output, you will see that it
is not only HTML, but could also consist of CSS, static text and JavaScript
depending on the Web Forms control you were using. And, in this example the
resulting code would contain NOT the RGB value, but a CLIENT side reference
to Gainsboro. Try it for yourself and see.

Quote:
The Color struct cotains definitions for a set number of colors. If you
want to use a colour that is not provided, then you use the RGB
representation instead.
Gee, that sounds like what I said.


Quote:
"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote in message
news:OHxTe9apFHA.3256 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
While the Properties window does show Gainsboro in the list, remember
that the values you select in the Properties window for web forms
controls must be able to be expressed (or better yet, rendered) to the
client (browser) as something the browser will understand. This is why a
Web Forms control might start out as: <ASP:Button>, but it winds up in
the client as <INPUT TYPE="Submit">. The same is true with property
values. The only way to specify a background color for an HTML control
is via Cascading Style Sheets and the STYLE attribute of the <INPUT> tag.

Now, here's the important part: in CSS, Gainsboro is a valid value for
the "background-color:" style sheet property, BUT there are 2 additional
things to consider...

1. Gainsboro is just a name that your video card must be able to present
to you. Not everyone has the same video card that you have and it is
quite possible that many people's systems will have no idea what
Gainsboro is.

2. Even though on your system Gainsboro is a known color and even though
the Cascading Style Sheet language accepts Gainsboro as a value for the
"background-color:" style property, when you are working in .NET code,
you are not working in the Cascading Style Sheet language. You are
working in a different language that will be processed by a web server
and the .NET Framework, not a client browser and a video card. Because
of this, you must use the Color class. Microsoft certainly can't create
constant values in the color class for every color there is, so they
created constants exposed as properties for quite a few common colors.
For all other colors, they gave us the "FromARGB" method to "mix" up a
color as we see fit.

To get the RGB of virtually any named color, a simple Google search on:
"gainsboro rgb" returns as the very first result, that 220, 220, 220 is
the RGB for Gainsboro.


-Scott


"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:4306cde4$0$17495$ed2e19e4 (AT) ptn-nntp-reader04 (DOT) plus.net...
When I manually look at the properties of a web control and check it's
backcolor, I see that the color 'Gainsboro' has been selected from the
web color palette. Is it true that in code you cannot change a
control's backcolor to another color from the web palette?

I am a novice programmer, but this seems very strange that you need to
reference code color changes using RGB references, when manually you can
using defined named colors. If this is the case where do you get the
RGB values for each names colour?

PWS



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote in message
news:e9J6ZeRpFHA.764 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
color.fromArgb(rr, gg, bb)

where rr, gg, bb are the red, green and blue values that should be
mixed to produce the color you desire.

Microsoft can supply the color class with every color under the sun.
They've provided a good base of colors, but for custom colors, you'll
need to supply the ingredients yourself.



"Paul Smith" <pws (AT) twelve (DOT) me.uk> wrote in message
news:43066b16$0$97123$ed2619ec (AT) ptn-nntp-reader03 (DOT) plus.net...
I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

Help!













Reply With Quote
  #9  
Old   
Zanna
 
Posts: n/a

Default Re: Colors - 08-27-2005 , 05:54 AM



"Paul Smith" <pws (AT) twelve (DOT) me.uk> ha scritto nel messaggio
news:43066b16$0$97123$ed2619ec@ptn-nntp-

Quote:
I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.
What is the error?

in C# (case sensitive) you need to write

btnSample.BackColor = Color.Gainsboro;

It's really no matther if the value came from the Web palette or it is in
RGB: it's a System.Drawing.Color and this is all you need.

--
..Net Reporting tool: http://www.neodatatype.net




Reply With Quote
  #10  
Old   
Scott M.
 
Posts: n/a

Default Re: Colors - 08-27-2005 , 12:17 PM



The problem is that Gainsboro doesn't get converted to an RGB when the code
is delivered to the client. Cascading Style Sheet code is produced with the
color name Gainsboro still intact. The use of the color name in the client
code is producing different colors depending on the client that is receiving
the code. There is no error message.

If you've read this thread, you'll see that the solution is not to use the
color name Gainsboro and to use the RGB value for it instead.

"Zanna" <znt.fabio (AT) virgilio (DOT) it> wrote

Quote:
"Paul Smith" <pws (AT) twelve (DOT) me.uk> ha scritto nel messaggio
news:43066b16$0$97123$ed2619ec@ptn-nntp-

I have a button on my web page the backcolor of which I want to change:

btnSample.backcolor = ????????

I want the color to be Gainsboro

However I enter Gainsboro or color.Gainsboro I have the blue wavy line
indicating an error.

What is the error?

in C# (case sensitive) you need to write

btnSample.BackColor = Color.Gainsboro;

It's really no matther if the value came from the Web palette or it is in
RGB: it's a System.Drawing.Color and this is all you need.

--
.Net Reporting tool: http://www.neodatatype.net





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.