Setting Web Colors in C#

G

Guest

I'm having trouble figuring out which objects and what syntax to use to set Web Control Colors using RGB values from Code-Behind

Let's say I have a control WebCtl and I want to set it's BackColor to "#ffee22" dynamically in CS code. I can't find a color object that I use. Is it this COlorConverter class? I'm confused about how to use it

WebCtl.BackColor = ???

Thanks

Alex
 
M

Mark Fitzpatrick

Make sure that you have the system.drawing namespace imported first. Then
you can use the
System.Drawing.Color.FromArgb() method to get the correct color like so:
WebCtl.BackColor = System.Drawing.Color.FromArgb(255,238,34);

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage


Alex Maghen said:
I'm having trouble figuring out which objects and what syntax to use to
set Web Control Colors using RGB values from Code-Behind.
Let's say I have a control WebCtl and I want to set it's BackColor to
"#ffee22" dynamically in CS code. I can't find a color object that I use. Is
it this COlorConverter class? I'm confused about how to use it.
 
G

Guest

That'll do it! Thanks

Ale

----- Mark Fitzpatrick wrote: ----

Make sure that you have the system.drawing namespace imported first. The
you can use th
System.Drawing.Color.FromArgb() method to get the correct color like so
WebCtl.BackColor = System.Drawing.Color.FromArgb(255,238,34)

Hope this helps
Mark Fitzpatric
Microsoft MVP - FrontPag


Alex Maghen said:
I'm having trouble figuring out which objects and what syntax to use t
set Web Control Colors using RGB values from Code-Behind"#ffee22" dynamically in CS code. I can't find a color object that I use. I
it this COlorConverter class? I'm confused about how to use it
 
Joined
Nov 9, 2006
Messages
3
Reaction score
0
For future reference

Use System.Drawing.ColorTranslator.FromHtml() and ToHtml() to do this easily.
Chris.-
 

Ask a Question

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

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

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top