Question : Color Translator

I am using a Rad Color Picker and need to laod the Hex code into my database.

When I do a var= RadColorpicker1.SelectedColor.ToString()
This is what gets sent to my database
 Color [A=255, R=102, G=0, B=51]

I actually need to translate that to #990033 (or whatever...)

Answer : Color Translator

  // Store the color as a hex number

   //  string HexColor = string.Format("0x{0:X8}", clrPicker.Color.ToArgb());  // Original
   string HexColor = string.Format("0x{0:X8}", RadColorpicker1.SelectedColor.ToArgb());

   // Strip the unnecessary characters at the end of the hex number

   txtHex.Text = "#" + HexColor.Substring(HexColor.Length - 6, 6);

HTH
Ashok
Random Solutions  
 
programming4us programming4us