Setting Web Colors in C#

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 15, 2004.

  1. 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
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 15, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    Mark Fitzpatrick, May 15, 2004
    #2
    1. Advertising

  3. 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" <> wrote in messag
    news:..
    > I'm having trouble figuring out which objects and what syntax to use t

    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 t

    "#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
    >> WebCtl.BackColor = ???
    >> Thanks
    >> Ale
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 15, 2004
    #3
  4. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    camelinckx

    Joined:
    Nov 9, 2006
    Messages:
    3
    For future reference

    Use System.Drawing.ColorTranslator.FromHtml() and ToHtml() to do this easily.
    Chris.-
    camelinckx, Jun 15, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Meade

    Setting table cell colors?

    Rob Meade, Jun 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    3,080
    Rob Meade
    Jun 7, 2004
  2. brucie
    Replies:
    2
    Views:
    802
    brucie
    Jul 1, 2003
  3. Web safe colors

    , Sep 12, 2006, in forum: HTML
    Replies:
    6
    Views:
    500
    Nikita the Spider
    Sep 13, 2006
  4. AAaron123

    TreeNode colors come from anchor colors

    AAaron123, Aug 7, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    527
    darrel
    Aug 7, 2008
  5. ZelluX
    Replies:
    3
    Views:
    1,857
    Peter Otten
    Dec 1, 2008
Loading...

Share This Page