This is a migrated thread and some comments may be shown as answers.

Color Picker save/load values

1 Answer 266 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Nelson
Top achievements
Rank 1
Nelson asked on 12 Oct 2011, 07:56 PM
I'm trying to use the color picker to load and save values. My values are stored in normal HTML format (#000000). The demos show that you can set the selected color in the control property like so: SelectedColor = "#000000" however the property is really a System.Drawing.Color type. You cannot set the property like this: ColorPicker.SelectedColor = "#000000"; in the code. Instead you must convert the HTML string to System.Drawing.Color.

This seems so basic, I think I must be missing something. Are there no built in routines to allow us to easily load and save HTML colors or do we really have to convert everything to and from the database?

Can you give me two examples of the recommended way of setting and getting an HTML color value from code?

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 17 Oct 2011, 01:32 PM
Hello Nelson,

Currently you can get and set the current color of a RadColorPicker programmatically only through a System.Drawing.Color type. Nevertheless, you can easily convert a hex color code to and from a System.Drawing.Color through the static methods FromHtml and ToHtml of the System.Drawing.ColorTranslator class. For your convenience I have attached a sample page, demonstrating getting and setting an HTML color value from code. Please use it as a reference for your further development.

I hope that helps.

Kind regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ColorPicker
Asked by
Nelson
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or