By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,567 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,567 IT Pros & Developers. It's quick & easy.

Colors

P: n/a
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!
Nov 19 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader03.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!

Nov 19 '05 #2

P: n/a
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-***@nospam.nospam> wrote in message
news:e9*************@TK2MSFTNGP14.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader03.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!


Nov 19 '05 #3

P: n/a
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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader04.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-***@nospam.nospam> wrote in message
news:e9*************@TK2MSFTNGP14.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader03.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!



Nov 19 '05 #4

P: n/a
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-***@nospam.nospam> wrote in message
news:OH**************@TK2MSFTNGP12.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader04.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-***@nospam.nospam> wrote in message
news:e9*************@TK2MSFTNGP14.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader03.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!



Nov 19 '05 #5

P: n/a
No problem. Good luck.
"Paul Smith" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader03.plus.net...
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-***@nospam.nospam> wrote in message
news:OH**************@TK2MSFTNGP12.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader04.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-***@nospam.nospam> wrote in message
news:e9*************@TK2MSFTNGP14.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader03.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!
>
>



Nov 19 '05 #6

P: n/a
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-***@nospam.nospam> wrote in message
news:OH**************@TK2MSFTNGP12.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader04.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-***@nospam.nospam> wrote in message
news:e9*************@TK2MSFTNGP14.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader03.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!



Nov 19 '05 #7

P: n/a

"Brendan Green" <bg****@simtap.com.au> wrote in message
news:Ow**************@TK2MSFTNGP15.phx.gbl...
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.

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.

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.
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.


"Scott M." <s-***@nospam.nospam> wrote in message
news:OH**************@TK2MSFTNGP12.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader04.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-***@nospam.nospam> wrote in message
news:e9*************@TK2MSFTNGP14.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader03.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!
>
>



Nov 19 '05 #8

P: n/a
"Paul Smith" <pw*@twelve.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
Nov 19 '05 #9

P: n/a
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" <zn*******@virgilio.it> wrote in message
news:HD*********************@news4.tin.it...
"Paul Smith" <pw*@twelve.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

Nov 19 '05 #10

P: n/a

"Scott M." <s-***@nospam.nospam> wrote in message
news:ul**************@TK2MSFTNGP10.phx.gbl...

"Brendan Green" <bg****@simtap.com.au> wrote in message
news:Ow**************@TK2MSFTNGP15.phx.gbl...
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.


No, you don't get Gainsboro. You get something that is converted down.
Still, the video card has no impact to the generation of the website. The
browser takes the value Gainsboro and converts it to some color that is used
when rendering the page. Get it? The browser takes care of the colours,
the video card just display's what it is given.

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.


You're missing the point. The browsers *rendering engine* is responsible
for displaying the web page. If its a known colour in, say, CSS, then the
browser will know what to do with it, and display it appropriately.

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.


So you get CSS and static text? So what, I missed a couple of TLA's? The
end result is something that gets interpreted by the browser. I am trying
to make the distinction between server side and client side processing.
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.


Yes, I am reiterating the fact, which I thought would be prudent, given that
some of the earlier stuff that you wrote was confusing, and not related to
the problem at hand.

"Scott M." <s-***@nospam.nospam> wrote in message
news:OH**************@TK2MSFTNGP12.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader04.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-***@nospam.nospam> wrote in message
news:e9*************@TK2MSFTNGP14.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" <pw*@twelve.me.uk> wrote in message
> news:43***********************@ptn-nntp-reader03.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!
>>
>>
>
>



Nov 19 '05 #11

P: n/a
You are missing the point completely. I do "get it" and have "gotten it"
for the last 15 years since I've been doing and teaching "it". I never said
the video card has an impact on the code generated for the web site (and
yet, you keep telling me that I'm wrong and that I did). I said that color
names should not be used because different video cards will render different
CLIENT side color names differently (it doesn't matter if the browser
translates Gainsboro into an RGB if that is an RGB the video card can't
render correctly).

In short, you should not be using color names in CLIENT side code. If you
use Color.Gainsboro (SERVER code), the CLR will NOT convert that to an RGB
value to be sent to the CLIENT. It creates CSS for the control and
continues to refer to Gainsboro and round and round we go.

Now, lets consider that it is entirely possible with some of the more
obscure color names that different browsers are going to interpret what RGB
the color name should be translated to, which will result in different
colors being seen in the client.
"Brendan Green" <bg****@simtap.com.au> wrote in message
news:Ox**************@TK2MSFTNGP09.phx.gbl...

"Scott M." <s-***@nospam.nospam> wrote in message
news:ul**************@TK2MSFTNGP10.phx.gbl...

"Brendan Green" <bg****@simtap.com.au> wrote in message
news:Ow**************@TK2MSFTNGP15.phx.gbl...
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.


No, you don't get Gainsboro. You get something that is converted down.
Still, the video card has no impact to the generation of the website. The
browser takes the value Gainsboro and converts it to some color that is
used when rendering the page. Get it? The browser takes care of the
colours, the video card just display's what it is given.

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.


You're missing the point. The browsers *rendering engine* is responsible
for displaying the web page. If its a known colour in, say, CSS, then the
browser will know what to do with it, and display it appropriately.

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.


So you get CSS and static text? So what, I missed a couple of TLA's? The
end result is something that gets interpreted by the browser. I am trying
to make the distinction between server side and client side processing.
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.


Yes, I am reiterating the fact, which I thought would be prudent, given
that some of the earlier stuff that you wrote was confusing, and not
related to the problem at hand.

"Scott M." <s-***@nospam.nospam> wrote in message
news:OH**************@TK2MSFTNGP12.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" <pw*@twelve.me.uk> wrote in message
news:43***********************@ptn-nntp-reader04.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-***@nospam.nospam> wrote in message
> news:e9*************@TK2MSFTNGP14.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" <pw*@twelve.me.uk> wrote in message
>> news:43***********************@ptn-nntp-reader03.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!
>>>
>>>
>>
>>
>
>



Nov 19 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.